@Test public void values() { GaussianNoise gaussian = new GaussianNoise(10.0, 10.0, 1.0); VDouble firstValue = gaussian.nextValue(); assertThat(firstValue.getLowerCtrlLimit(), equalTo(-30.0)); assertThat(firstValue.getLowerDisplayLimit(), equalTo(-30.0)); assertThat(firstValue.getLowerAlarmLimit(), equalTo(-10.0)); assertThat(firstValue.getLowerWarningLimit(), equalTo(0.0)); assertThat(firstValue.getUpperWarningLimit(), equalTo(20.0)); assertThat(firstValue.getUpperAlarmLimit(), equalTo(30.0)); assertThat(firstValue.getUpperDisplayLimit(), equalTo(50.0)); assertThat(firstValue.getUpperCtrlLimit(), equalTo(50.0)); int quart1 = 0; int quart2 = 0; int quart3 = 0; int quart4 = 0; for (int i = 0; i < 100000; i++) { double value = gaussian.nextValue().getValue(); if (value < 10.0) { if (value < 0.0) { quart1++; } else { quart2++; } } else { if (value < 20.0) { quart3++; } else { quart4++; } } } assertTrue(quart1 < 16870); assertTrue(quart2 < 35130); assertTrue(quart3 < 35130); assertTrue(quart4 < 16870); assertEquals(100000, quart1+quart2+quart3+quart4); }
@Override VDouble nextValue() { return newValue(average + rand.nextGaussian() * stdDev, lastValue); }
GaussianNoise extends SimFunction<VDouble> { @Override VDouble nextValue() { return newValue(average + rand.nextGaussian() * stdDev, lastValue); } }
GaussianNoise extends SimFunction<VDouble> { @Override VDouble nextValue() { return newValue(average + rand.nextGaussian() * stdDev, lastValue); } GaussianNoise();  GaussianNoise(Double average, Double stdDev, Double interval); }
GaussianNoise extends SimFunction<VDouble> { @Override VDouble nextValue() { return newValue(average + rand.nextGaussian() * stdDev, lastValue); } GaussianNoise();  GaussianNoise(Double average, Double stdDev, Double interval);  }
GaussianNoise extends SimFunction<VDouble> { @Override VDouble nextValue() { return newValue(average + rand.nextGaussian() * stdDev, lastValue); } GaussianNoise();  GaussianNoise(Double average, Double stdDev, Double interval);   }