@Test public void estimateDensity(){ ContinuousDistribution distribution = new GaussianDistribution(5d, Math.pow(1.5d, 2d)); assertEquals(0.00759732d, DistributionUtil.probability(distribution, 1d), 1e-8); assertEquals(0.10934005d, DistributionUtil.probability(distribution, 3d), 1e-8); assertEquals(0.26596152d, DistributionUtil.probability(distribution, 5d), 1e-8); }
static public double probability(ContinuousDistribution distribution, Number x){ if(distribution instanceof GaussianDistribution){ return probability((GaussianDistribution)distribution, x); } else if(distribution instanceof PoissonDistribution){ return probability((PoissonDistribution)distribution, x); } throw new UnsupportedElementException(distribution); }
DistributionUtil { static public double probability(ContinuousDistribution distribution, Number x){ if(distribution instanceof GaussianDistribution){ return probability((GaussianDistribution)distribution, x); } else if(distribution instanceof PoissonDistribution){ return probability((PoissonDistribution)distribution, x); } throw new UnsupportedElementException(distribution); } }
DistributionUtil { static public double probability(ContinuousDistribution distribution, Number x){ if(distribution instanceof GaussianDistribution){ return probability((GaussianDistribution)distribution, x); } else if(distribution instanceof PoissonDistribution){ return probability((PoissonDistribution)distribution, x); } throw new UnsupportedElementException(distribution); } private  DistributionUtil(); }
DistributionUtil { static public double probability(ContinuousDistribution distribution, Number x){ if(distribution instanceof GaussianDistribution){ return probability((GaussianDistribution)distribution, x); } else if(distribution instanceof PoissonDistribution){ return probability((PoissonDistribution)distribution, x); } throw new UnsupportedElementException(distribution); } private  DistributionUtil(); static double probability(ContinuousDistribution distribution, Number x); static double probability(GaussianDistribution gaussianDistribution, Number x); static double probability(PoissonDistribution poissonDistribution, Number x); }
DistributionUtil { static public double probability(ContinuousDistribution distribution, Number x){ if(distribution instanceof GaussianDistribution){ return probability((GaussianDistribution)distribution, x); } else if(distribution instanceof PoissonDistribution){ return probability((PoissonDistribution)distribution, x); } throw new UnsupportedElementException(distribution); } private  DistributionUtil(); static double probability(ContinuousDistribution distribution, Number x); static double probability(GaussianDistribution gaussianDistribution, Number x); static double probability(PoissonDistribution poissonDistribution, Number x);  }