use of org.apache.commons.math3.random.GaussianRandomGenerator in project metron by apache.
the class OnlineStatisticsProviderTest method testNormallyDistributedRandomDataShiftedBackwards.
@Test
public void testNormallyDistributedRandomDataShiftedBackwards() {
List<Double> values = new ArrayList<>();
GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
for (int i = 0; i < 1000000; ++i) {
double d = gaussian.nextNormalizedDouble() - 10;
values.add(d);
}
validateEquality(values);
}
use of org.apache.commons.math3.random.GaussianRandomGenerator in project metron by apache.
the class OnlineStatisticsProviderTest method testNormallyDistributedRandomDataShifted.
@Test
public void testNormallyDistributedRandomDataShifted() {
List<Double> values = new ArrayList<>();
GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
for (int i = 0; i < 1000000; ++i) {
double d = gaussian.nextNormalizedDouble() + 10;
values.add(d);
}
validateEquality(values);
}
use of org.apache.commons.math3.random.GaussianRandomGenerator in project metron by apache.
the class StellarStatisticsFunctionsTest method testMergeProviders.
@Test
public void testMergeProviders() throws Exception {
List<StatisticsProvider> providers = new ArrayList<>();
/*
Create 10 providers, each with a sample drawn from a gaussian distribution.
Update the reference stats from commons math to ensure we are
*/
GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(1L));
SummaryStatistics sStatistics = new SummaryStatistics();
DescriptiveStatistics dStatistics = new DescriptiveStatistics();
for (int i = 0; i < 10; ++i) {
List<Double> sample = new ArrayList<>();
for (int j = 0; j < 100; ++j) {
double s = gaussian.nextNormalizedDouble();
sample.add(s);
sStatistics.addValue(s);
dStatistics.addValue(s);
}
StatisticsProvider provider = (StatisticsProvider) run("STATS_ADD(STATS_INIT(), " + Joiner.on(",").join(sample) + ")", new HashMap<>());
providers.add(provider);
}
/*
Merge the providers and validate
*/
Map<String, Object> providerVariables = new HashMap<>();
for (int i = 0; i < providers.size(); ++i) {
providerVariables.put("provider_" + i, providers.get(i));
}
StatisticsProvider mergedProvider = (StatisticsProvider) run("STATS_MERGE([" + Joiner.on(",").join(providerVariables.keySet()) + "])", providerVariables);
OnlineStatisticsProviderTest.validateStatisticsProvider(mergedProvider, sStatistics, dStatistics);
}
use of org.apache.commons.math3.random.GaussianRandomGenerator in project metron by apache.
the class OnlineStatisticsProviderTest method testNormallyDistributedRandomData.
@Test
public void testNormallyDistributedRandomData() {
List<Double> values = new ArrayList<>();
GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
for (int i = 0; i < 1000000; ++i) {
double d = gaussian.nextNormalizedDouble();
values.add(d);
}
validateEquality(values);
}
use of org.apache.commons.math3.random.GaussianRandomGenerator in project metron by apache.
the class OnlineStatisticsProviderTest method testNormallyDistributedRandomDataAllNegative.
@Test
public void testNormallyDistributedRandomDataAllNegative() {
List<Double> values = new ArrayList<>();
GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
for (int i = 0; i < 1000000; ++i) {
double d = -1 * gaussian.nextNormalizedDouble();
values.add(d);
}
validateEquality(values);
}
Aggregations