@@ -37,7 +37,7 @@ def corrcoef(xs, ys):
3737
3838 returns: float
3939 """
40- return np .corrcoef (xs , ys , ddof = 0 )[0 , 1 ]
40+ return np .corrcoef (xs , ys )[0 , 1 ]
4141
4242
4343def plot_sines ():
@@ -64,7 +64,7 @@ def plot_sines():
6464 wave2 = make_sine (offset )
6565 corr = corrcoef (wave1 .ys , wave2 .ys )
6666 corrs .append (corr )
67-
67+
6868 thinkplot .plot (offsets , corrs )
6969 thinkplot .save (root = 'autocorr2' ,
7070 xlabel = 'Offset (radians)' ,
@@ -125,7 +125,7 @@ def plot_serial_corr():
125125
126126 thinkplot .plot (betas , corrs )
127127 thinkplot .config (xlabel = r'Pink noise parameter, $\beta$' ,
128- ylabel = 'Serial correlation' ,
128+ ylabel = 'Serial correlation' ,
129129 ylim = [0 , 1.05 ])
130130 thinkplot .save (root = 'autocorr3' )
131131
@@ -162,9 +162,9 @@ def plot_autocorr():
162162 label = r'$\beta$ = %.1f' % beta
163163 plot_pink_autocorr (beta , label )
164164
165- thinkplot .config (xlabel = 'Lag' ,
166- ylabel = 'Correlation' ,
167- xlim = [- 5 , 1000 ],
165+ thinkplot .config (xlabel = 'Lag' ,
166+ ylabel = 'Correlation' ,
167+ xlim = [- 5 , 1000 ],
168168 ylim = [- 0.05 , 1.05 ])
169169 thinkplot .save (root = 'autocorr4' )
170170
@@ -185,8 +185,8 @@ def plot_singing_chirp():
185185 # plot the autocorrelation function
186186 lags , corrs = autocorr (segment )
187187 thinkplot .plot (lags , corrs )
188- thinkplot .config (xlabel = 'Lag (index)' ,
189- ylabel = 'Correlation' ,
188+ thinkplot .config (xlabel = 'Lag (index)' ,
189+ ylabel = 'Correlation' ,
190190 ylim = [- 1.05 , 1.05 ],
191191 xlim = [0 , 225 ])
192192 thinkplot .save (root = 'autocorr8' )
@@ -195,12 +195,12 @@ def plot_singing_chirp():
195195 gram = wave .make_spectrogram (seg_length = 1024 )
196196 gram .plot (high = 4200 )
197197
198- thinkplot .config (xlabel = 'Time (s)' ,
198+ thinkplot .config (xlabel = 'Time (s)' ,
199199 ylabel = 'Frequency (Hz)' ,
200200 xlim = [0 , 1.4 ],
201201 ylim = [0 , 4200 ])
202202 thinkplot .save (root = 'autocorr5' )
203-
203+
204204 # plot the spectrum of one segment
205205 spectrum = segment .make_spectrum ()
206206 spectrum .plot (high = 1000 )
@@ -221,8 +221,8 @@ def plot_correlate():
221221 corrs2 = np .correlate (segment .ys , segment .ys , mode = 'same' )
222222 lags = np .arange (- N // 2 , N // 2 )
223223 thinkplot .plot (lags , corrs2 )
224- thinkplot .config (xlabel = 'Lag' ,
225- ylabel = 'Correlation' ,
224+ thinkplot .config (xlabel = 'Lag' ,
225+ ylabel = 'Correlation' ,
226226 xlim = [- N // 2 , N // 2 ])
227227 thinkplot .save (root = 'autocorr9' )
228228
0 commit comments