当前位置: 首页>>代码示例>>Java>>正文


Java NormalDistribution.cumulativeProbability方法代码示例

本文整理汇总了Java中org.apache.commons.math3.distribution.NormalDistribution.cumulativeProbability方法的典型用法代码示例。如果您正苦于以下问题:Java NormalDistribution.cumulativeProbability方法的具体用法?Java NormalDistribution.cumulativeProbability怎么用?Java NormalDistribution.cumulativeProbability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.distribution.NormalDistribution的用法示例。


在下文中一共展示了NormalDistribution.cumulativeProbability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: solveLognormalNewsvendor

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
public static Newsvendor solveLognormalNewsvendor (final double price, final double cost, final double mu, final double sigma) {
	final NormalDistribution dist1 = new NormalDistribution();
	final double cv = sigma/mu;
	final double nu = Math.log(mu)-Math.log(Math.sqrt(1+cv*cv));
	final double tau = Math.sqrt(Math.log(1+cv*cv));
	final LogNormalDistribution dist2 = new LogNormalDistribution(nu,tau);
	return new Newsvendor(price,cost) {{
		_safetyfactor = dist1.inverseCumulativeProbability((price-cost)/price);
		_quantity = Math.exp(nu+tau*_safetyfactor);
		_profit = (price-cost)*mu - price*mu*dist1.cumulativeProbability(tau-_safetyfactor)+cost*mu;
	}
	@Override
	public double getProfit(double quantity) {
		double lostSales = quantity*(1-dist2.cumulativeProbability(quantity))-Math.exp(nu+tau*tau/2)*dist1.cumulativeProbability((nu+tau*tau-Math.log(quantity))/tau);
		return _price*mu -_cost*quantity + _price*lostSales;
	}
	};
}
 
开发者ID:loehndorf,项目名称:scengen,代码行数:19,代码来源:Newsvendor.java

示例2: test

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * Testing code...
 * @param args
 */
public static void test() {
	final NormalDistribution dist_1 = new NormalDistribution(-1,1);
	final NormalDistribution dist0 = new NormalDistribution(0,1);
	final NormalDistribution dist1 = new NormalDistribution(1,1);
	final UnivariateFunction F = new UnivariateFunction() {				
		@Override
		public double value(double x) {
			double val = dist_1.cumulativeProbability(x)*dist0.cumulativeProbability(x)*dist1.cumulativeProbability(x);
			return val;
		}
	};
	double v;
	long t = System.currentTimeMillis();
	v = calculateEV_KG(F);
    System.out.println("calculateEV_KG "+v+" "+(System.currentTimeMillis()-t));
}
 
开发者ID:pszufe,项目名称:pkg,代码行数:21,代码来源:CalculateEv.java

示例3: calculateAsymptoticPValue

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * @param Wmin smallest Wilcoxon signed rank value
 * @param N number of subjects (corresponding to x.length)
 * @return two-sided asymptotic p-value
 */
private double calculateAsymptoticPValue(final double Wmin, final int N) {

    final double ES = (double) (N * (N + 1)) / 4.0;

    /* Same as (but saves computations):
     * final double VarW = ((double) (N * (N + 1) * (2*N + 1))) / 24;
     */
    final double VarS = ES * ((double) (2 * N + 1) / 6.0);

    // - 0.5 is a continuity correction
    final double z = (Wmin - ES - 0.5) / FastMath.sqrt(VarS);

    // No try-catch or advertised exception because args are valid
    // pass a null rng to avoid unneeded overhead as we will not sample from this distribution
    final NormalDistribution standardNormal = new NormalDistribution(null, 0, 1);

    return 2*standardNormal.cumulativeProbability(z);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:24,代码来源:WilcoxonSignedRankTest.java

示例4: calculateAsymptoticPValue

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * @param Umin smallest Mann-Whitney U value
 * @param n1 number of subjects in first sample
 * @param n2 number of subjects in second sample
 * @return two-sided asymptotic p-value
 * @throws ConvergenceException if the p-value can not be computed
 * due to a convergence error
 * @throws MaxCountExceededException if the maximum number of
 * iterations is exceeded
 */
private double calculateAsymptoticPValue(final double Umin,
                                         final int n1,
                                         final int n2)
    throws ConvergenceException, MaxCountExceededException {

    /* long multiplication to avoid overflow (double not used due to efficiency
     * and to avoid precision loss)
     */
    final long n1n2prod = (long) n1 * n2;

    // http://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U#Normal_approximation
    final double EU = n1n2prod / 2.0;
    final double VarU = n1n2prod * (n1 + n2 + 1) / 12.0;

    final double z = (Umin - EU) / FastMath.sqrt(VarU);

    // No try-catch or advertised exception because args are valid
    // pass a null rng to avoid unneeded overhead as we will not sample from this distribution
    final NormalDistribution standardNormal = new NormalDistribution(null, 0, 1);

    return 2 * standardNormal.cumulativeProbability(z);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:33,代码来源:MannWhitneyUTest.java

示例5: checkLUT

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
@Test
public void checkLUT() {
    int numElements =
            (int)((NormalDist.MAXZSCORE - NormalDist.MINZSCORE)/NormalDist.GRANULARITY) + 1;
    double[] LUT = new double[numElements];
    NormalDistribution dist = new NormalDistribution();
    int minKey = (int) Math.round(NormalDist.MINZSCORE / NormalDist.GRANULARITY);
    int maxKey = (int) Math.round(NormalDist.MAXZSCORE / NormalDist.GRANULARITY);
    int offset = -minKey;
    for (int i = minKey; i <= maxKey; i ++) {
        double zscore = i * NormalDist.GRANULARITY;
        LUT[i+offset] = dist.cumulativeProbability(zscore);
    }

    assertEquals(NormalDist.CDF_LUT.length, LUT.length);
    for (int i = 0; i < LUT.length; i++) {
        assertEquals(NormalDist.CDF_LUT[i], LUT[i], 0.001);
    }
}
 
开发者ID:stanford-futuredata,项目名称:macrobase,代码行数:20,代码来源:NormalDistTest.java

示例6: densityPruning

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * Estimating the size of a context
 * The Null Hypothesis is that density(c) >= minDensity
 *
 * @param c
 * @param minDensity
 * @return true if the estimation > minSize
 */
private boolean densityPruning(Context c, double minDensity) {
    if (densityPruning == false)
        return false;
    int sampleSize = globalSample.size();
    int sampleHit = c.getSample().size();
    double estimatedDensity = (double) sampleHit / sampleSize;
    double sampleSD = Math.sqrt(minDensity * (1 - minDensity) / sampleSize);
    double zScore = (estimatedDensity - minDensity) / sampleSD;
    NormalDistribution unitNormal = new NormalDistribution(0d, 1d);
    double pValue = unitNormal.cumulativeProbability(zScore);
    if (pValue <= alpha) {
        return true;
    } else {
        //fail to reject
        return false;
    }
}
 
开发者ID:stanford-futuredata,项目名称:macrobase,代码行数:26,代码来源:Context.java

示例7: compute

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
  * Compute the (Naive) Merton Distance-to-Default measure for an agent
  * in a specified forecast timeframe T.
  * 
  * @param debtFaceValue (F)
  *        The face value of the agent debt.
  * @param equityVolatility
  *        The volatility of agent equity.
  * @param equity (E)
  *        The current agent equity.
  * @param expectedAssetReturn
  *        The asset return of the agent during the last forecast window.
  * @param forecastHorizon (T)
  *        The period over which to forecast agent default.
  * @return
  *        A Pair<Double, Double> in the format:
  *        Pair<Naive Merton Distance-to-Default, Naive Merton
  *        Probability-of-Default>, in the period of the forecast timeframe.
  * 
  * It is not permissible for: both the debt face value (F) and equity (E)
  * aguments to be simultaneously zero; for the debt face value (F) to be
  * negative; or for the forecase horizon (T) to be zero or negative. If the 
  * debt face value is zero and equity is nonzero, then the distance to 
  * default is taken to be +Infinity.
  */
static Pair<Double, Double> compute(
   final double debtFaceValue,
   final double equityVolatility,
   final double equity,
   final double expectedAssetReturn,
   final double forecastHorizon
   ) {
   Preconditions.checkArgument(equity != 0. || debtFaceValue > 0.);
   Preconditions.checkArgument(forecastHorizon > 0.);
   Preconditions.checkArgument(debtFaceValue >= 0.);
   final double
      debtVolatility = .05 + .25 * equityVolatility,
      overallValueVolatility =
         equityVolatility * equity / (equity + debtFaceValue) +
         debtVolatility * debtFaceValue / (equity + debtFaceValue);
   double
      distanceToDefault = Math.log((equity + debtFaceValue)/debtFaceValue) +
         (expectedAssetReturn - .5 * overallValueVolatility * overallValueVolatility) * 
            forecastHorizon;
   distanceToDefault /= Math.sqrt(forecastHorizon) * overallValueVolatility;
   NormalDistribution normalDist = new NormalDistribution();
   final double
      defaultProbability = normalDist.cumulativeProbability(-distanceToDefault);
   return Pair.create(distanceToDefault, defaultProbability);
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:51,代码来源:NaiveMertonDistanceToDefaultAlgorithm.java

示例8: calculateAsymptoticPValue

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * @param Wmin smallest Wilcoxon signed rank value
 * @param N number of subjects (corresponding to x.length)
 * @return two-sided asymptotic p-value
 */
private double calculateAsymptoticPValue(final double Wmin, final int N) {

    final double ES = (double) (N * (N + 1)) / 4.0;

    /* Same as (but saves computations):
     * final double VarW = ((double) (N * (N + 1) * (2*N + 1))) / 24;
     */
    final double VarS = ES * ((double) (2 * N + 1) / 6.0);

    // - 0.5 is a continuity correction
    final double z = (Wmin - ES - 0.5) / FastMath.sqrt(VarS);

    final NormalDistribution standardNormal = new NormalDistribution(0, 1);

    return 2*standardNormal.cumulativeProbability(z);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:WilcoxonSignedRankTest.java

示例9: calculateAsymptoticPValue

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * @param Umin smallest Mann-Whitney U value
 * @param n1 number of subjects in first sample
 * @param n2 number of subjects in second sample
 * @return two-sided asymptotic p-value
 * @throws ConvergenceException if the p-value can not be computed
 * due to a convergence error
 * @throws MaxCountExceededException if the maximum number of
 * iterations is exceeded
 */
private double calculateAsymptoticPValue(final double Umin,
                                         final int n1,
                                         final int n2)
    throws ConvergenceException, MaxCountExceededException {

    /* long multiplication to avoid overflow (double not used due to efficiency
     * and to avoid precision loss)
     */
    final long n1n2prod = (long) n1 * n2;

    // http://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U#Normal_approximation
    final double EU = n1n2prod / 2.0;
    final double VarU = n1n2prod * (n1 + n2 + 1) / 12.0;

    final double z = (Umin - EU) / FastMath.sqrt(VarU);

    final NormalDistribution standardNormal = new NormalDistribution(0, 1);

    return 2 * standardNormal.cumulativeProbability(z);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:31,代码来源:MannWhitneyUTest.java

示例10: calculateAsymptoticPValue

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * @param Wmin smallest Wilcoxon signed rank value
 * @param N number of subjects (corresponding to x.length)
 * @return two-sided asymptotic p-value
 */
private double calculateAsymptoticPValue(final double Wmin, final int N) {

    final double ES = (double) (N * (N + 1)) / 4.0;

    /* Same as (but saves computations):
     * final double VarW = ((double) (N * (N + 1) * (2*N + 1))) / 24;
     */
    final double VarS = ES * ((double) (2 * N + 1) / 6.0);

    // - 0.5 is a continuity correction
    final double z = (Wmin - ES - 0.5) / FastMath.sqrt(VarS);

    // No try-catch or advertised exception because args are valid
    final NormalDistribution standardNormal = new NormalDistribution(0, 1);

    return 2*standardNormal.cumulativeProbability(z);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:WilcoxonSignedRankTest.java

示例11: calculateAsymptoticPValue

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * @param Umin smallest Mann-Whitney U value
 * @param n1 number of subjects in first sample
 * @param n2 number of subjects in second sample
 * @return two-sided asymptotic p-value
 * @throws ConvergenceException if the p-value can not be computed
 * due to a convergence error
 * @throws MaxCountExceededException if the maximum number of
 * iterations is exceeded
 */
private double calculateAsymptoticPValue(final double Umin,
                                         final int n1,
                                         final int n2)
    throws ConvergenceException, MaxCountExceededException {

    /* long multiplication to avoid overflow (double not used due to efficiency
     * and to avoid precision loss)
     */
    final long n1n2prod = (long) n1 * n2;

    // http://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U#Normal_approximation
    final double EU = n1n2prod / 2.0;
    final double VarU = n1n2prod * (n1 + n2 + 1) / 12.0;

    final double z = (Umin - EU) / FastMath.sqrt(VarU);

    // No try-catch or advertised exception because args are valid
    final NormalDistribution standardNormal = new NormalDistribution(0, 1);

    return 2 * standardNormal.cumulativeProbability(z);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:MannWhitneyUTest.java

示例12: determineSignificance

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * Determines the significance for the given {@link Itemset} by modeling the background normal distribution.
 *
 * @param itemset The {@link Itemset} for which the significance should be calculated.
 */
private void determineSignificance(Itemset<LabelType> itemset) {

    double[] values = backgroundDistributions.get(itemset).getObservations().stream()
                                             .mapToDouble(Double::doubleValue).toArray();

    // model normal distribution
    DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics(values);
    double mean = descriptiveStatistics.getMean();
    double standardDeviation = descriptiveStatistics.getStandardDeviation();
    NormalDistribution normalDistribution = new NormalDistribution(mean, standardDeviation);

    // calculate KS p-value to estimate quality of fit
    double ks = TestUtils.kolmogorovSmirnovTest(normalDistribution, values, false);
    if (ks < ksCutoff) {
        logger.warn("itemset {} background distribution of type {} violates KS-cutoff, skipping", itemset, type);
        return;
    }

    double pValue = Double.NaN;
    if (type == SignificanceEstimatorType.COHESION) {
        pValue = normalDistribution.cumulativeProbability(itemset.getCohesion());
    } else if (type == SignificanceEstimatorType.CONSENSUS) {
        pValue = normalDistribution.cumulativeProbability(itemset.getConsensus());
    } else if (type == SignificanceEstimatorType.AFFINITY) {
        pValue = normalDistribution.cumulativeProbability(itemset.getAffinity());
    }

    logger.debug("p-value for itemset {} is {}", itemset.toSimpleString(), pValue);
    if (pValue < significanceCutoff) {
        Significance significance = new Significance(pValue, ks);
        significantItemsets.put(significance, itemset);
        logger.info("itemset {} is significant with {}", itemset.toSimpleString(), significance);
    }
}
 
开发者ID:enauz,项目名称:mmm,代码行数:40,代码来源:SignificanceEstimator.java

示例13: solveNormalNewsvendor

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
public static Newsvendor solveNormalNewsvendor (final double price, final double cost, final double mu, final double sigma) {
	final NormalDistribution dist = new NormalDistribution();
	return new Newsvendor(price,cost) {{
		_safetyfactor = dist.inverseCumulativeProbability((price-cost)/price);
		_quantity = mu+sigma*_safetyfactor;
		_profit = (price-cost)*mu - price*sigma*dist.density(_safetyfactor);
	}
	@Override
	public double getProfit(double quantity) {
		double z = (quantity-mu)/sigma;
		double lostSales = sigma*(dist.density(z)-z*(1-dist.cumulativeProbability(z)));
		return _price*mu -_cost*quantity - _price*lostSales;
	}
	};
}
 
开发者ID:loehndorf,项目名称:scengen,代码行数:16,代码来源:Newsvendor.java

示例14: generateExpectedPatientsMap

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
private void generateExpectedPatientsMap() {
    NormalDistribution xND = new NormalDistribution(MAP_SIZE.getLeft() / 2, MAP_SIZE.getLeft() / 4);
    NormalDistribution yND = new NormalDistribution(MAP_SIZE.getRight() / 2, MAP_SIZE.getRight() / 4);

    for (int x = 0; x < MAP_SIZE.getLeft(); x++)
        for (int y = 0; y < MAP_SIZE.getRight(); y++) {
            double xProb = xND.cumulativeProbability(x) - xND.cumulativeProbability(x - 1);
            double nX = xProb * MAP_SIZE.getLeft() * MAP_SIZE.getRight();

            double yProb = xND.cumulativeProbability(y) - xND.cumulativeProbability(y - 1);
            int nXY = (int) Math.round(yProb * nX);

            this.expectedPatientsMap.setValue(x, y, nXY);
        }
}
 
开发者ID:SESoS,项目名称:SIMVA-SoS,代码行数:16,代码来源:MCIResponseWorld.java

示例15: alignPeakPeaks

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
double alignPeakPeaks(Map.Entry peak, HashMap peaks, double deviation)
{
    NormalDistribution d = new NormalDistribution(); 
    double mass = (Double) peak.getKey();
    double maxprob = 0;
    for (Object p : peaks.keySet())
    {
        double massCand = (Double) p;
        double z = Math.abs(mass - massCand)/deviation;
        double prob = 1 - d.cumulativeProbability(-z,z);
        if (prob > maxprob)
            maxprob = prob;
    }
    return maxprob;
}
 
开发者ID:skumsp,项目名称:MassSpec,代码行数:16,代码来源:SpecOperator.java


注:本文中的org.apache.commons.math3.distribution.NormalDistribution.cumulativeProbability方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。