Presentation is loading. Please wait.

Presentation is loading. Please wait.

Descriptive Statistics I: By the end of this class you should be able to: Palm: Section 7.1, 7.2 Program cords and delays in your music programs plot a.

Similar presentations


Presentation on theme: "Descriptive Statistics I: By the end of this class you should be able to: Palm: Section 7.1, 7.2 Program cords and delays in your music programs plot a."— Presentation transcript:

1 Descriptive Statistics I: By the end of this class you should be able to: Palm: Section 7.1, 7.2 Program cords and delays in your music programs plot a histogram of absolute frequencies and describe its nature vary the number of bins in a histogram and choose an appropriate number plot a histogram of relative frequencies and explain why it is needed.

2 Practice Problem (groups of 3): A debugging a Sine Series Function The sin function can be approximated by the series: Download the function: SinSeries1.m from the website This function was developed to estimate the sine using the above series given the x-value and n, the number of terms to be used in the sequence. Follow the instructions on the worksheet handout.

3 Problem Goal (brief): Develop a function that will estimate the sine for a given number of terms in the sine series Inputs: NameDescriptionUnits or ValuesInput Source * xThe number to take the sine ofRadiansCommand line nThe number of terms in the seriesIntegerCommand line Outputs: NameDescriptionUnits or ValuesOutput type * SResulting sinUnitlessCommand line Test Case: for x =0.5, n = 3 sin(0.5) = (0.5) – (0.5) 3 /6 + (0.5) 5 /120 = 0.5 – 0.02083 + 0.00026 = 0.479427 Versus the exact value for sin sin(0.5) = 0.479426

4 Flowchart for Sine Series Problem

5 Working with Chords download “chordplay.m” from the “Music in MATLAB’ page Open this script in the MATLAB editor. Exercise instructions and questions are in the comments of this script. Please write down answers to these questions. To “uncomment” remove the “%” from the beginning of a line Exercises 1: Play a major chord 1.What are the names for these three notes? 2.What advantage can you see to calculating them this way instead of just typing in the frequencies? 3.How are the three note series combined into one series/chord. Exercise 2: Add a delay 4.How is the delay created? 5.Why is the pad added at the end of the first note twice? 6.What are the dimensions of the chord array? Exercise 3: Play two notes in stereo 7. What are the dimensions of the chord array now?

6 Saving and Loading.wav files Loading.wav files: >> [series, sf, bits] = wavread(‘wavfile’) Saving a.wav: >> wavwrite (series, sf, bits, ‘filename’) Import Wizard: File  Import Data

7 Characteristics of a stored ware Series: The list of y- values for the wave. Sampling Frequency: how many times per second you have a data point = 1/(interval between points) Bits: The number of significant figures used in the y-values (in binary) 8 bits = 256 levels 16 bits = 65,536 levels 24 bits = 16 x 10 6 levels

8 Descriptive Statistics please download cordbreak1.mat & load into MATLAB Palm: Section 7.1, 7.2

9 Plot of Cordbreak data download cordbreak from web page Load into MATLAB >> load cordbreak Plot the data: >> plot(cord,’p’) 60 tests of the force required to break a cord shows variation, like most real data (it is stochastic) how can we show this variability?

10 Histogram: a frequency plot >> hist(cord) >> xlabel 'breaking force (N)' >> ylabel 'absolute frequency '

11 breaking strength bins Number of occurrences in a bin The x- range is divided into a series of bins – small ranges – the number of occurrences in each bin is then counted.

12 Some things to notice: a graph of how something varies  descriptive most data has a central tendency and then drops off toward the edges. the chosen bins are very important. By default MatLAB chooses 10 bins. this is a plot of absolute frequency = the actual number of observations in each bin this histogram is dependent on the total sample size. As the sample size gets larger, the height of the bars will increase.

13 Histogram Bins Bins can greatly effect the look of a histogram By default MATLAB uses 10 bins Adjusting bins in MATLAB: >> hist(cord, n) where n is the number of bins desired Exercise: Create a figure with four plots arranged 2x2 where the plots are histograms of the cordbreak data with bin numbers of 10, 20, 5 and 7.

14 >> subplot(2,2,1) >> hist(cord) >> xlabel 'breaking force (N)' >> ylabel 'absolute frequency' >> title 'ten bins‘ >> subplot(2,2,2) >> hist(cord,20) >> title 'twenty bins‘ >> subplot(2,2,3) >> hist(cord,5) >> title 'five bins‘ >> subplot(2,2,4) >> hist(cord,7) >> title 'seven bins'

15 Histogram Commands >> hist (data)  histogram with 10 equal width bins >> hist(data, number of bins)  histogram with specified number of bins >> [z, x] = hist(data)  no histogram produced  outputs a vector of heights (z) and the center point of each bin (x) try using this command. Then try >> bar(x, z) >> hist(data, vector of bin centers)  bins are centered at the provided values

16 Relative Frequency Histogram Try this: >> [z,x]=hist(cord); >> zr=z/sum(z) >> bar(x,zr) add axis labels etc. Frequency is relative to the total number of samples (N). Each bar is the fraction of samples in that bin This histogram is independent of total sample size

17 The resulting relative frequency histogram

18 How can we quantify central tendency? Mean (average) Quantifying Central Tendency & Variability (ask class)

19 How can we quantify spread? difference from mean  results in vector of deviations data – mean sum the differences  gives one number but effected by sample sz.  (data – mean) normalize by sample size (minus one)  independent of sample sz.  (data – mean)/(n-1) take square root Standard Deviation:

20 FormulaMATLABEXCEL Mean >> mean(variable)= average(range) Sample Standard Deviation >> std(variable)= stdev(range)


Download ppt "Descriptive Statistics I: By the end of this class you should be able to: Palm: Section 7.1, 7.2 Program cords and delays in your music programs plot a."

Similar presentations


Ads by Google