public GaussianDistribution(double[] values) { // Logger.getAnonymousLogger().info(String.valueOf(values.length)); // 1. mean double sum = 0; for (double v : values) sum += v; this.mean = sum / values.length; // System.out.println(this.mean); // 2. variance double[] deltas = values.clone(); for (int i = 0; i < values.length; i++) { double diff = values[i] - this.mean; deltas[i] = diff * diff; } sum = 0; for (double v : deltas) sum += v; this.variance = sum / (values.length - 1); // 3. standard deviation this.standardDeviation = Math.sqrt(this.variance); }
public GaussianDistribution(double mean, double deviance) { this.mean = mean; this.variance = deviance; this.standardDeviation = Math.sqrt(deviance); }