Java Code Examples for org.apache.commons.math3.random.GaussianRandomGenerator#nextNormalizedDouble()
The following examples show how to use
org.apache.commons.math3.random.GaussianRandomGenerator#nextNormalizedDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OnlineStatisticsProviderTest.java From metron with Apache License 2.0 | 5 votes |
@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); }
Example 2
Source File: OnlineStatisticsProviderTest.java From metron with Apache License 2.0 | 5 votes |
@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); }
Example 3
Source File: OnlineStatisticsProviderTest.java From metron with Apache License 2.0 | 5 votes |
@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); }
Example 4
Source File: OnlineStatisticsProviderTest.java From metron with Apache License 2.0 | 5 votes |
@Test public void testNormallyDistributedRandomDataSkewed() { List<Double> values = new ArrayList<>(); GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L)); for(int i = 0;i < 1000000;++i) { double d = (gaussian.nextNormalizedDouble()+ 10000) /1000; values.add(d); } validateEquality(values); }
Example 5
Source File: OnlineStatisticsProviderTest.java From metron with Apache License 2.0 | 5 votes |
@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); }
Example 6
Source File: StatisticalBinningPerformanceDriver.java From metron with Apache License 2.0 | 5 votes |
public static void main(String... argv) { DescriptiveStatistics perfStats = new DescriptiveStatistics(); OnlineStatisticsProvider statsProvider = new OnlineStatisticsProvider(); List<Double> values = new ArrayList<>(); GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L)); for(int i = 0;i < NUM_DATA_POINTS;++i) { //get the data point out of the [0,1] range double d = 1000*gaussian.nextNormalizedDouble(); values.add(d); statsProvider.addValue(d); } for(int perfRun = 0;perfRun < NUM_RUNS;++perfRun) { StellarStatisticsFunctions.StatsBin bin = new StellarStatisticsFunctions.StatsBin(); long start = System.currentTimeMillis(); Random r = new Random(0); for (int i = 0; i < TRIALS_PER_RUN; ++i) { //grab a random value and fuzz it a bit so we make sure there's no cheating via caching in t-digest. bin.apply(ImmutableList.of(statsProvider, values.get(r.nextInt(values.size())) - 3.5, PERCENTILES)); } perfStats.addValue(System.currentTimeMillis() - start); } System.out.println( "Min/25th/50th/75th/Max Milliseconds: " + perfStats.getMin() + " / " + perfStats.getPercentile(25) + " / " + perfStats.getPercentile(50) + " / " + perfStats.getPercentile(75) + " / " + perfStats.getMax() ); }
Example 7
Source File: UniformSamplerTest.java From metron with Apache License 2.0 | 5 votes |
@BeforeAll public static void beforeClass() { Random rng = new Random(0); GaussianRandomGenerator gen = new GaussianRandomGenerator(new MersenneTwister(0)); for(int i = 0;i < SAMPLE_SIZE;++i) { double us= 10*rng.nextDouble(); uniformSample.add(us); uniformStats.addValue(us); double gs= 10*gen.nextNormalizedDouble(); gaussianSample.add(gs); gaussianStats.addValue(gs); } }
Example 8
Source File: StellarStatisticsFunctionsTest.java From metron with Apache License 2.0 | 5 votes |
@Test public void testMergeProviders() { 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); }