descriptive statistics i: by the end of this class you should be able to: palm: section 7.1, 7.2...
TRANSCRIPT
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.
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.
n
k
kk
k
xxxxx
1
12*1
53
)!12*()1(
!5!3)sin(
function S = SinSeries(x,n)
Calculate first termS = x
for terms 2 through n
S = S + new term
End
Done with index array
Flowchart for Sine Series Problem
Working with Chordsdownload “chordplay.m” from the “Music in MATLAB’ pageOpen 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 stereo7. 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
0 0.5 1 1.5 2 2.5
x 10-3
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time(sec.)
ampl
itude
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 levels16 bits = 65,536 levels24 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
Formula MATLAB EXCEL
Mean >> mean(variable)
= average(range)
Sample Standard Deviation
>> std(variable) = stdev(range)
n
xx
n
ii
1
1
)(1
2
n
xxs
n
ii
x