120 likes | 213 Views
Descriptive Statistics I: By the end of this class you should be able to:. 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
E N D
Descriptive Statistics I:By the end of this class you should be able to: • 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. Palm: Section 7.1, 7.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.
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 • What are the names for these three notes? • What advantage can you see to calculating them this way instead of just typing in the frequencies? • 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?
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
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 106 levels
Descriptive Statistics please download cordbreak1.mat& load into MATLAB Palm: Section 7.1, 7.2
Histogram: a frequency plot >> hist(cord) >> xlabel 'breaking force (N)' >> ylabel 'absolute frequency'
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.
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
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