| 160 | |
| 161 | @check_figures_equal() |
| 162 | def test_acorr(fig_test, fig_ref): |
| 163 | np.random.seed(19680801) |
| 164 | Nx = 512 |
| 165 | x = np.random.normal(0, 1, Nx).cumsum() |
| 166 | maxlags = Nx-1 |
| 167 | |
| 168 | ax_test = fig_test.subplots() |
| 169 | ax_test.acorr(x, maxlags=maxlags) |
| 170 | |
| 171 | ax_ref = fig_ref.subplots() |
| 172 | # Normalized autocorrelation |
| 173 | norm_auto_corr = np.correlate(x, x, mode="full")/np.dot(x, x) |
| 174 | lags = np.arange(-maxlags, maxlags+1) |
| 175 | norm_auto_corr = norm_auto_corr[Nx-1-maxlags:Nx+maxlags] |
| 176 | ax_ref.vlines(lags, [0], norm_auto_corr) |
| 177 | ax_ref.axhline(y=0, xmin=0, xmax=1) |
| 178 | |
| 179 | |
| 180 | @check_figures_equal() |