package distributions public class NormalDistribution implements Distr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package distributions;
public class NormalDistribution implements Distribution
{
private double sigma, mu;
public NormalDistribution(double sigma, double mu)
{
this.sigma = sigma;
this.mu = mu;
}
@Override
public double getProbability(double x, double y)
{
return getProbability(x) * getProbability(y);
}
@Override
public double getProbability(double x)
{
return Math.exp(-Math.pow(x - mu, 2) / (2 * sigma * sigma));
}
}