List of usage examples for org.apache.commons.math3.distribution NormalDistribution NormalDistribution
public NormalDistribution(double mean, double sd) throws NotStrictlyPositiveException
From source file:eu.crisis_economics.abm.model.parameters.ParameterUtils.java
/** * Create a model parameter with a double value drawn from a * normal distribution.// w w w . j av a 2s . com * * @param parameterName * The name of the model parameter. * @param mean * The minimum value of the paremeter. * @param stdDeviation * The maximum value of the parameter. */ public static ModelParameter<?> createParameterWithNormalDistribution(final String parameterName, final double mean, final double stdDeviation) { Preconditions.checkArgument(stdDeviation >= 0.); return new FromRealDistributionModelParameter(new NormalDistribution(mean, stdDeviation), parameterName); }
From source file:es.us.isa.sedl.module.statcharts.renderer.HighChartsRenderer.java
private String[][] generateNormalDistribution(HistogramResult histogramResult) { Integer total = 0;//from ww w . ja v a2 s . c om for (String value : histogramResult.getCounts()) total += Integer.valueOf(value); Double mean = Double.valueOf(histogramResult.getMean()); Double sigma = Double.valueOf(histogramResult.getSigma()); NormalDistribution normal = new NormalDistribution(mean, sigma); Double[] xPoints = { -3.2807020192309, -3.0425988742109, -2.8044957291909, -2.5663925841709, -2.3282894391509, -2.0901862941309, -1.8520831491109, -1.6139800040909, -1.3758768590709, -1.1377737140509, -0.89967056903087, -0.66156742401087, -0.42346427899086, -0.18536113397085, 0.052742011049155, 0.29084515606916, 0.52894830108917, 0.76705144610918, 1.0051545911292, 1.2432577361492, 1.4813608811692, 1.7194640261892, 1.9575671712092, 2.1956703162292, 2.4337734612492, 2.6718766062692, 2.9099797512892, 3.1480828963092 }; String[][] result = new String[xPoints.length][2]; for (int i = 0; i < xPoints.length; i++) { result[i][0] = String.valueOf(mean + xPoints[i] * sigma); result[i][1] = String.valueOf(normal.density(mean + xPoints[i] * sigma) * total); } return result; }
From source file:ffx.algorithms.mc.CoordShakeMove.java
public void setSigma(double sigma) { this.sigma = sigma; dist = new NormalDistribution(0, sigma); }
From source file:de.bund.bfr.math.LodFunction.java
@Override public double value(double[] point) { double sd = Double.NaN; for (int ip = 0; ip < nParams; ip++) { if (parameters.get(ip).equals(sdParam)) { sd = Math.abs(point[ip]); } else {// w ww.j ava 2 s . co m parser.setVarValue(parameters.get(ip), point[ip]); } } if (sd == 0.0) { return Double.NaN; } double logLikelihood = 0.0; for (int iv = 0; iv < nValues; iv++) { for (Map.Entry<String, List<Double>> entry : variableValues.entrySet()) { parser.setVarValue(entry.getKey(), entry.getValue().get(iv)); } try { double value = parser.evaluate(function); if (!Double.isFinite(value)) { return Double.NaN; } NormalDistribution normDist = new NormalDistribution(value, sd); logLikelihood += targetValues.get(iv) > levelOfDetection ? Math.log(normDist.density(targetValues.get(iv))) : Math.log(normDist.cumulativeProbability(levelOfDetection)); } catch (ParseException e) { e.printStackTrace(); return Double.NaN; } } return logLikelihood; }
From source file:adams.data.distribution.Normal.java
/** * Returns the configured distribution.// ww w . j av a 2s . c om * * @return the distribution */ @Override public RealDistribution getRealDistribution() { return new NormalDistribution(m_Mean, m_StandardDeviation); }
From source file:me.datamining.cluster.STING.java
/** * //from ww w .j a v a 2s . c o m * @param value * @param mean * @param std * @return */ public static double standardPDF(double value, double mean, double std) { if (std == 0) { return 0; } NormalDistribution sdf = new NormalDistribution(mean, std); try { return sdf.cumulativeProbability(value); } catch (NumberIsTooLargeException e) { return 0; } }
From source file:com.lyncode.performance.PerformanceRequester.java
public long normalDist() { NormalDistribution distribution = new NormalDistribution(average(), desvio()); long sum = 0; double sumProb = 0; for (long value : measurements) { double probability = distribution.probability(value); sumProb += probability;// w w w. j a v a 2 s .c om double result = (double) value * probability; sum += result; } double value = (double) sum / sumProb; return (long) value; }
From source file:de.huberlin.wbi.hiway.scheduler.WienerProcessModel.java
public double getEstimate(double timestamp, double alpha) { if (alpha == 0.5 && measurements.size() > 0) { return logarithmize ? Math.pow(Math.E, measurements.getLast().runtime) : Math.max(measurements.getLast().runtime, Double.MIN_NORMAL); }/* w w w. j a va2 s .co m*/ if (differences.size() < 2) { return 0d; } Runtime lastMeasurement = measurements.getLast(); double variance = 0d; double avgDifference = sumOfDifferences / differences.size(); for (double difference : differences) { variance += Math.pow(difference - avgDifference, 2d); } variance /= differences.size() - 1; variance *= timestamp - lastMeasurement.timestamp; double estimate = lastMeasurement.runtime; if (variance > 0d) { NormalDistribution nd = new NormalDistribution(lastMeasurement.runtime, Math.sqrt(variance)); estimate = nd.inverseCumulativeProbability(alpha); } estimate = logarithmize ? Math.pow(Math.E, estimate) : Math.max(estimate, 0d); return estimate; }
From source file:com.itemanalysis.psychometrics.distribution.NormalDistributionApproximation.java
private void initialize(double min, double max, double mean, double sd) { //create points double range = max - min; points = new double[numberOfPoints]; double step = range / ((double) numberOfPoints - 1.0); points[0] = min;//from w w w . j a va 2 s . c o m for (int i = 1; i < numberOfPoints; i++) { points[i] = points[i - 1] + step; } //compute density NormalDistribution normal = new NormalDistribution(mean, sd); density = new double[numberOfPoints]; double densitySum = 0.0; for (int i = 0; i < numberOfPoints; i++) { density[i] = normal.density(points[i]); densitySum += density[i]; } //make sure probabilities sum to unity for (int i = 0; i < numberOfPoints; i++) { density[i] = density[i] / densitySum; } }
From source file:gedi.util.math.stat.distributions.OccupancyNumberDistribution.java
private double[] computeApproximateNormal() { int maxA = getMaximalA(); double[] re = new double[maxA + 1]; if (normal == null) normal = new NormalDistribution(expectation(), sqrt(variance())); for (int a = 0; a <= maxA; a++) { re[a] = normal.density(a);/* w w w . ja v a 2 s . c o m*/ } ArrayUtils.normalize(re); return re; }