List of usage examples for org.apache.commons.math3.distribution NormalDistribution NormalDistribution
public NormalDistribution(double mean, double sd) throws NotStrictlyPositiveException
From source file:org.jpmml.evaluator.NormalDistributionUtil.java
static public double probability(double mean, double stdev, double x) { NormalDistribution normalDistribution = new NormalDistribution(mean, stdev); return normalDistribution.density(x); }
From source file:org.jreserve.jrlib.util.random.RndNormalTest.java
@Before public void setUp() { rnd = new RndNormal(new JavaRandom(SEED)); nd = new NormalDistribution(MEAN, SIGMA); }
From source file:org.lightjason.trafficsimulation.math.EDistributionFactory.java
/** * generate the distribution/*from w w w .ja va 2 s.c om*/ * * @param p_args distribution arguments * @return the distribution */ public final AbstractRealDistribution generate(final double... p_args) { switch (this) { case BETA: return new BetaDistribution(p_args[0], p_args[1]); case CAUCHY: return new CauchyDistribution(p_args[0], p_args[1]); case CHI_SQUARED: return new ChiSquaredDistribution(p_args[0]); case EXPONENTIAL: return new ExponentialDistribution(p_args[0]); case F: return new FDistribution(p_args[0], p_args[1]); case GAMMA: return new GammaDistribution(p_args[0], p_args[1]); case GUMBEL: return new GumbelDistribution(p_args[0], p_args[1]); case LAPLACE: return new LaplaceDistribution(p_args[0], p_args[1]); case LEVY: return new LevyDistribution(p_args[0], p_args[1]); case LOGISTIC: return new LogisticDistribution(p_args[0], p_args[1]); case LOG_NORMAL: return new LogNormalDistribution(p_args[0], p_args[1]); case NAKAGAMI: return new NakagamiDistribution(p_args[0], p_args[1]); case NORMAL: return new NormalDistribution(p_args[0], p_args[1]); case PARETO: return new ParetoDistribution(p_args[0], p_args[1]); case T: return new TDistribution(p_args[0]); case TRIANGULAR: return new TriangularDistribution(p_args[0], p_args[1], p_args[2]); case UNIFORM: return new UniformRealDistribution(p_args[0], p_args[1]); case WEIBULL: return new WeibullDistribution(p_args[0], p_args[1]); default: throw new RuntimeException(MessageFormat.format("not set {0}", this)); } }
From source file:org.powertac.customer.coldstorage.ColdStorage.java
private void ensureSeeds() { if (null == opSeed) { opSeed = randomSeedRepo.getRandomSeed(ColdStorage.class.getName() + "-" + name, 0, "model"); evalSeed = randomSeedRepo.getRandomSeed(ColdStorage.class.getName() + "-" + name, 0, "eval"); normal01 = new NormalDistribution(0.0, 1.0); normal01.reseedRandomGenerator(opSeed.nextLong()); }//from w ww . j a va2 s .c o m }
From source file:org.powertac.customer.model.LiftTruck.java
private void ensureSeeds() { if (null == opSeed) { RandomSeedRepo repo = service.getRandomSeedRepo(); opSeed = repo.getRandomSeed(LiftTruck.class.getName() + "-" + name, 0, "model"); evalSeed = repo.getRandomSeed(LiftTruck.class.getName() + "-" + name, 0, "eval"); normal = new NormalDistribution(0.0, 1.0); normal.reseedRandomGenerator(opSeed.nextLong()); }//from w ww . j a va 2s. c om }
From source file:org.powertac.genco.CpGenco.java
public void init(BrokerProxy proxy, int seedId, RandomSeedRepo randomSeedRepo, TimeslotRepo timeslotRepo) { log.info("init(" + seedId + ") " + getUsername()); this.brokerProxyService = proxy; this.timeslotRepo = timeslotRepo; // set up the random generator this.seed = randomSeedRepo.getRandomSeed(CpGenco.class.getName(), seedId, "bid"); normal01 = new NormalDistribution(0.0, 1.0); normal01.reseedRandomGenerator(seed.nextLong()); // set up the supply-curve generating function if (!function.validateCoefficients(coefficients)) log.error("wrong number of coefficients for quadratic"); int to = Competition.currentCompetition().getTimeslotsOpen(); timeslotCoefficients = new double[to][getCoefficients().size()]; }
From source file:org.ranksys.novdiv.reranking.DitheringReranker.java
@Override public int[] rerankPermutation(Recommendation<U, I> recommendation, int maxLength) { List<Tuple2od<I>> items = recommendation.getItems(); int M = items.size(); int N = min(maxLength, M); if (variance == 0.0) { return getBasePerm(N); }/*from ww w. j av a 2 s.c o m*/ NormalDistribution dist = new NormalDistribution(0.0, sqrt(variance)); IntDoubleTopN topN = new IntDoubleTopN(N); for (int i = 0; i < M; i++) { topN.add(M - i, log(i + 1) + dist.sample()); } topN.sort(); return topN.stream().mapToInt(e -> M - e.v1).toArray(); }
From source file:org.rhwlab.segmentation.GaussianMixtureEM.java
License:asdf
private void M_Step() { for (int k = 0; k < K; ++k) { N[k] = 0.0;//from w w w. j a v a 2 s .com for (int n = 0; n < source.getN(); ++n) { N[k] = N[k] + r[n][k]; } // compute the mean double sum = 0; for (int n = 0; n < source.getN(); ++n) { sum = sum + r[n][k] * source.get(n).getIntensity(); } mu[k] = sum / N[k]; // compute the SD; double var = 0.0; double mean = mu[k]; for (int n = 0; n < source.getN(); ++n) { double del = source.get(n).getIntensity() - mean; var = var + r[n][k] * del * del; } sigma[k] = Math.sqrt(var / N[k]); lnpi[k] = Math.log(N[k] / source.getN()); try { normal[k] = new NormalDistribution(mu[k], sigma[k]); } catch (Exception exc) { int ashdf = 0; } } }
From source file:org.workflowsim.failure.FailureGenerator.java
/** * *//*from w w w .j a va 2 s. c o m*/ protected static RealDistribution getDistribution(double alpha, double beta) { RealDistribution distribution = null; switch (FailureParameters.getFailureDistribution()) { case LOGNORMAL: distribution = new LogNormalDistribution(1.0 / alpha, beta); break; case WEIBULL: distribution = new WeibullDistribution(beta, 1.0 / alpha); break; case GAMMA: distribution = new GammaDistribution(beta, 1.0 / alpha); break; case NORMAL: //beta is the std, 1.0/alpha is the mean distribution = new NormalDistribution(1.0 / alpha, beta); break; default: break; } return distribution; }
From source file:org.workflowsim.utils.DistributionGenerator.java
/** * Gets the RealDistribution with two parameters * * @param scale the first param scale// w w w .j a v a 2 s .c o m * @param shape the second param shape * @return the RealDistribution Object */ public RealDistribution getDistribution(double scale, double shape) { RealDistribution distribution = null; switch (this.dist) { case LOGNORMAL: distribution = new LogNormalDistribution(scale, shape); break; case WEIBULL: distribution = new WeibullDistribution(shape, scale); break; case GAMMA: distribution = new GammaDistribution(shape, scale); break; case NORMAL: //shape is the std, scale is the mean distribution = new NormalDistribution(scale, shape); break; default: break; } return distribution; }