Add python code for generating expected
@@ -12,11 +12,11 @@ import static org.junit.Assert.assertThat;
public class SampleStatsTest {
@Test
- public void randomlyGeneratedSamplesHaveCloseToZeroAutocorrelation() {
+ public void randomlyGeneratedSamplesHaveCloseToZeroAutocorrelationAtLowLags() {
ContinuousDistribution uniform = Uniform.withParameters(DoubleTensor.ZERO_SCALAR, DoubleTensor.scalar(1000));
- uniform.sample(new long[]{100}, KeanuRandom.getDefaultRandom());
- double samples[] = new double[100];
- for(int i = 0; i < 100; i++) {
+ uniform.sample(new long[]{500}, KeanuRandom.getDefaultRandom());
+ double samples[] = new double[500];
+ for (int i = 0; i < 500; i++) {
samples[i] = uniform.sample(new long[]{1}, KeanuRandom.getDefaultRandom()).scalar();
}
double[] autocorr = SampleStats.acf(samples);
@@ -24,6 +24,12 @@ public class SampleStatsTest {
assertThat(autocorr[80], lessThan(0.1));
}
+ /*
+ import statsmodels.api as sm
+ import numpy as np
+ x = np.array([1,2,3,4,5,6,7,8])
+ print(sm.tsa.stattools.acf(x))
+ */
@Test
public void increasingSequenceReturnsCorrectAutocorr() {
double[] samples = {1, 2, 3, 4, 5, 6, 7, 8};
