Simple Statistics on Arrays

Slides:



Advertisements
Similar presentations
Iteration: WHILE Loop Damian Gordon. WHILE Loop Consider the problem of searching for an entry in a phone book with only SELECTION:
Advertisements

Searching Damian Gordon. Google PageRank Damian Gordon.
Sorting: Optimising Bubblesort Damian Gordon. Sorting: Bubble Sort If we look at the bubble sort algorithm again:
Data Structures: Arrays Damian Gordon. Arrays Imagine we had to record the age of everyone in the class, we could do it declaring a variable for each.
Python: Arrays Damian Gordon. Arrays In Python arrays are sometimes called “lists” or “tuple” but we’ll stick to the more commonly used term “array”.
Sorting: Selection Sort Damian Gordon. Sorting: Selection Sort OK, so we’ve seen a way of sorting that easy for the computer, now let’s look at a ways.
Prime Numbers Damian Gordon. Prime Numbers So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number.
Data Structures: Multi-Dimensional Arrays Damian Gordon.
Python: Iteration Damian Gordon. Python: Iteration We’ll consider four ways to do iteration: – The WHILE loop – The FOR loop – The DO loop – The LOOP.
Iteration: FOR, DO, LOOP Loop Damian Gordon. FOR Loop The FOR loop does the same thing as a WHILE loop but is easier if you are using the loop to do a.
Parameterization of Tabulated BRDFs Ian Mallett (me), Cem Yuksel
Chapter11 Authentication
Department of Informatics
Wide-band (wide-field) imaging Flagging + RFI
Examining the Feasibility of Long Term Care Insurance
Rural Investment and Policy Analysis (RIAPA) Modeling Toolkit
Investigating Forensics
1.5.2 Perfect Competition Unit Overview
Chemistry 200 Focus 1 Atoms.
Centralities (3) By: Ralucca Gera, NPS Excellence Through Knowledge.
Feasibility of Natural Gas Combined Cycle Utilization Targets: Evidence from Environmental Policy and Prices Kelly A. Stevens PhD Candidate in Public Administration.
How Much Should a Corporation Borrow?
Numbers in a Computer Unsigned integers Signed magnitude
Physics 3 – Sept 27, 2016 Do Now: P3 Challenge –
ME 475/675 Introduction to Combustion
Design of a low noise millimeter wave interferometer based on single sideband modulation Zhong Heng Tsinghua Univ. Gao Zhe, Professor Ling Bili, Professor.
An Application of the fundamental theorem of calculus: Rate graphs
Warm-Up: March 4, 2016 Find the exact value of cos sin −1 − 4 5.
Department of Petroleum Engineering
Superconducting Microwave Dirac Billiards: From Graphene to Fullerene
IoWA-PCIT (Integration of Working Models of Attachment into Parent Child Interaction Therapy) February, 2017.
ASTERICS Periodic Review 1
Exam Question: Homework due Friday, Jan 22nd
NeuroProtection with the TriGuard Embolic DEFLECTion Device
Cooling – Storage Ring & RF
REACH & Co Overview on current discussions and relevant ACEA initiatives CLEPA Materials Regulations Event 17th of May 2017 Reutlingen Timo Unger Manager.
ENVIRONMENTALLY SOUND
CRAI Projects Unit Conèixer la Biblioteca de ( ) 1.
Improving Prefetching Mechanisms for Tiled CMP Platforms
Going Up for the Rebound
AN INTRODUCTION TO FERMENTATION PROCESS
Ecotourism In the early days many definitions have been proposed, devised, dissected, deconstructed and again reconstructed...
Using Smart Beta to drive returns
BENEFICIAL MICRO ORGANISMS.
Individual, customed support
Independent Literacy Tasks for Second Grade Students Julianne Robinson
The Reproductive System
Promoting fairer distribution of wealth
RESISTANCE AND REBELLION (riot, protest, revolt, revolution)
My Career Project By: William Carrillo.
We are fond of pets Выполнила учитель английского языка
Youth & Young Adult Homelessness
Lesson 1.1: Fitness for Life Self-Assessment 1: Exercise Basics
Aqueous interfaces as seen by different vibrational modes of water
TVCG.
American Romanticism
Welcome to Interactive Chalkboard
Region 5 Fire and Aviation Management
Green Seal and 3rd Party Certified Ecolab Solutions
6 Penetential Psalms.
Key investment drivers in Iraq’s petroleum industry
Welcome to GE Wuhan Boiler Company Ltd.
Pseudocode (Revision)
Queues: Implemented using Arrays
Algorithmic Complexity
Simple Statistics on Arrays
Some Common Issues: Iteration
Sorting Damian Gordon.
Python: Sorting – Selection Sort
Week 13 - Wednesday CS221.
Presentation transcript:

Simple Statistics on Arrays Damian Gordon

Minimum Value in Array So let’s say we want to express the following algorithm: Find the minimum value in an array

Minimum Value in Array Here’s how we could do it: PROGRAM MinimumValue: integer ArraySize <- 8; MinValSoFar <- Age[0]; FOR N IN 1 TO ArraySize-1 DO IF MinValSoFar > Age[N] THEN MinValSoFar <- Age[N]; ENDIF; ENDFOR; PRINT MinValSoFar; END.

Maximum Value in Array So let’s say we want to express the following algorithm: Find the maximum value in an array

Maximum Value in Array Here’s how we could do it: PROGRAM MaximumValue: integer ArraySize <- 8; MaxValSoFar <- Age[0]; FOR N IN 1 TO ArraySize-1 DO IF MaxValSoFar < Age[N] THEN MaxValSoFar <- Age[N]; ENDIF; ENDFOR; PRINT MaxValSoFar; END.

Average Value in Array So let’s say we want to express the following algorithm: Find the average value of an array

Average Value in Array Here’s how we could do it: PROGRAM AverageValue: integer ArraySize <- 8; Integer Total <- 0; FOR N IN 1 TO ArraySize-1 DO Total <- Total + Age[N]; ENDFOR; PRINT Total/ArraySize; END.

Standard Deviation of an Array So let’s say we want to express the following algorithm: Find the standard deviation of an array

Standard Deviation of an Array So let’s say we want to express the following algorithm: Find the standard deviation of an array

Standard Deviation of an Array First Draft PROGRAM StandardDeviationValue: integer ArraySize <- 8; GET AVERAGE OF ARRAY; TotalSDNum <- 0; FOR N IN 0 TO ArraySize-1 DO SDNum <-(Age[N]-ArrayAvg)*(Age[N]-ArrayAvg) TotalSDNum <- TotalSDNum + SDNum; ENDFOR; Print SquareRoot(TotalSDNum/ArraySize-1); END.

Standard Deviation of an Array Here’s the final version: PROGRAM StandardDeviationValue: integer ArraySize <- 8; Integer TotalAvg <- 0; FOR N IN 1 TO ArraySize-1 DO TotalAvg <- TotalAvg + Age[N]; ENDFOR; AverageValue <- TotalAvg/ArraySize; TotalSDNum <- 0; FOR N IN 0 TO ArraySize-1 DO SDNum <-(Age[N]-AverageValue)*(Age[N]- AverageValue) TotalSDNum <- TotalSDNum + SDNum; Print SquareRoot(TotalSDNum/ArraySize-1); END.

etc.