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


Java TDistribution.inverseCumulativeProbability方法代码示例

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


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

示例1: solveStudentNewsvendor

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
public static Newsvendor solveStudentNewsvendor (final double price, final double cost, final double mu, final double scale, final double deg, final double[] sample) {
	final TDistribution dist = new TDistribution(deg);
	return new Newsvendor(price,cost) {{
		_safetyfactor = dist.inverseCumulativeProbability((price-cost)/price);
		_quantity = mu+scale*Math.sqrt((deg/(deg-2)))*_safetyfactor;
		_profit = getProfit(_quantity);
	}
	@Override
	public double getProfit(double quantity) {
		double profit = -quantity*cost;
		for (int i=0; i<sample.length; i++) {
			double demand = sample[i];
			profit += Math.min(quantity,demand)*price/sample.length;
		}
		return profit;
	}};
}
 
开发者ID:loehndorf,项目名称:scengen,代码行数:18,代码来源:Newsvendor.java

示例2: getConfidenceIntervalAt

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
/**
 * Returns the interval c1, c2 of which there's an 1-alpha
 * probability of the mean being within the interval.
 *
 * @param confidence level
 * @return the confidence interval
 */
@Override
public double[] getConfidenceIntervalAt(double confidence) {
    double[] interval = new double[2];

    if (getN() <= 2) {
        interval[0] = interval[1] = Double.NaN;
        return interval;
    }

    TDistribution tDist = new TDistribution(getN() - 1);
    double a = tDist.inverseCumulativeProbability(1 - (1 - confidence) / 2);
    interval[0] = getMean() - a * getStandardDeviation() / Math.sqrt(getN());
    interval[1] = getMean() + a * getStandardDeviation() / Math.sqrt(getN());

    return interval;
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:24,代码来源:AbstractStatistics.java

示例3: computeParameterSignificance

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
/**
 * Computes the T-stats and the P-Value for all regression parameters
 */
private void computeParameterSignificance(RealVector betaVector) {
    try {
        final double residualDF = frame.rows().count() - (regressors.size() + 1);
        final TDistribution distribution = new TDistribution(residualDF);
        final double interceptParam = betaVector.getEntry(0);
        final double interceptStdError = intercept.data().getDouble(0, Field.STD_ERROR);
        final double interceptTStat = interceptParam / interceptStdError;
        final double interceptPValue = distribution.cumulativeProbability(-Math.abs(interceptTStat)) * 2d;
        final double interceptCI = interceptStdError * distribution.inverseCumulativeProbability(1d - alpha / 2d);
        this.intercept.data().setDouble(0, Field.PARAMETER, interceptParam);
        this.intercept.data().setDouble(0, Field.T_STAT, interceptTStat);
        this.intercept.data().setDouble(0, Field.P_VALUE, interceptPValue);
        this.intercept.data().setDouble(0, Field.CI_LOWER, interceptParam - interceptCI);
        this.intercept.data().setDouble(0, Field.CI_UPPER, interceptParam + interceptCI);
        final int offset = hasIntercept() ? 1 : 0;
        for (int i=0; i<regressors.size(); ++i) {
            final C regressor = regressors.get(i);
            final double betaParam = betaVector.getEntry(i + offset);
            final double betaStdError = betas.data().getDouble(regressor, Field.STD_ERROR);
            final double tStat = betaParam / betaStdError;
            final double pValue = distribution.cumulativeProbability(-Math.abs(tStat)) * 2d;
            final double betaCI = betaStdError * distribution.inverseCumulativeProbability(1d - alpha / 2d);
            this.betas.data().setDouble(regressor, Field.PARAMETER, betaParam);
            this.betas.data().setDouble(regressor, Field.T_STAT, tStat);
            this.betas.data().setDouble(regressor, Field.P_VALUE, pValue);
            this.betas.data().setDouble(regressor, Field.CI_LOWER, betaParam - betaCI);
            this.betas.data().setDouble(regressor, Field.CI_UPPER, betaParam + betaCI);
        }
    } catch (Exception ex) {
        throw new DataFrameException("Failed to compute regression coefficient t-stats and p-values", ex);
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:36,代码来源:XDataFrameLeastSquares.java

示例4: calcMeanCI

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
private static double calcMeanCI(SummaryStatistics stats, double level) {
    try {
        TDistribution tDist = new TDistribution(stats.getN() - 1);
        double critVal = tDist.inverseCumulativeProbability(1.0 - (1 - level) / 2);
        return critVal * stats.getStandardDeviation() / Math.sqrt(stats.getN());
    } catch (MathIllegalArgumentException e) {
        return Double.NaN;
    }
}
 
开发者ID:dbunibas,项目名称:BART,代码行数:10,代码来源:EstimateRepairability.java

示例5: calcMeanCI

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
private static double calcMeanCI( SummaryStatistics stats, double level )
{
    // Create T Distribution with N-1 degrees of freedom
    TDistribution tDist = new TDistribution( stats.getN() - 1 );
    // Calculate critical value
    double critVal = tDist.inverseCumulativeProbability( 1.0 - ( 1 - level ) / 2 );
    // Calculate confidence interval
    return critVal * stats.getStandardDeviation() / Math.sqrt( stats.getN() );
}
 
开发者ID:RUB-NDS,项目名称:WS-Attacker,代码行数:10,代码来源:StatisticTest.java

示例6: getMeanErrorAt

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
@Override
public double getMeanErrorAt(double confidence) {
    if (getN() <= 2) return Double.NaN;
    TDistribution tDist = new TDistribution(getN() - 1);
    double a = tDist.inverseCumulativeProbability(1 - (1 - confidence) / 2);
    return a * getStandardDeviation() / Math.sqrt(getN());
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:8,代码来源:AbstractStatistics.java

示例7: getConfidenceInterval

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
/**
 * Adapted from https://gist.github.com/gcardone/5536578.
 *
 * @param alpha probability of incorrectly rejecting the null hypothesis (1
 * - confidence_level)
 * @param df degrees of freedom
 * @param n number of observations
 * @param std standard deviation
 * @param mean mean
 * @return array with the confidence interval: [mean - margin of error, mean
 * + margin of error]
 */
public static double[] getConfidenceInterval(final double alpha, final int df, final int n, final double std, final double mean) {
    // Create T Distribution with df degrees of freedom
    TDistribution tDist = new TDistribution(df);
    // Calculate critical value
    double critVal = tDist.inverseCumulativeProbability(1.0 - alpha);
    // Calculate confidence interval
    double ci = critVal * std / Math.sqrt(n);
    double lower = mean - ci;
    double upper = mean + ci;
    double[] interval = new double[]{lower, upper};
    return interval;
}
 
开发者ID:recommenders,项目名称:rival,代码行数:25,代码来源:ConfidenceInterval.java

示例8: getHalfwidth

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
/**
 * Returns the helf width of the confidence interval (e.g, for the 95% confidence interval alpha=0.95).
 * @return variance
 */
public double getHalfwidth(double alpha) {
	if (count<5) return Double.NaN;
	TDistribution t = new TDistribution(count);
	return t.inverseCumulativeProbability((1.+alpha)/2.)*getStandardError();
}
 
开发者ID:loehndorf,项目名称:scengen,代码行数:10,代码来源:Statistics.java

示例9: computeConfidenceInterval

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
private double computeConfidenceInterval(DescriptiveStatistics statistics, double significance)
{
    TDistribution tDist = new TDistribution(statistics.getN() - 1);
    double a = tDist.inverseCumulativeProbability(1.0 - significance / 2);
    return a * statistics.getStandardDeviation() / Math.sqrt(statistics.getN());
}
 
开发者ID:marcelovca90,项目名称:anti-spam-weka-gui,代码行数:7,代码来源:ExperimentHelper.java

示例10: computeConfidenceErrorMargin

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
/**
 * <p>
 * Computes the confidence interval error margin for a given set of samples
 * in order to enable finding the interval lower and upper bound around a
 * mean value. By this way, the confidence interval can be computed as [mean
 * + errorMargin .. mean - errorMargin].
 * </p>
 *
 * <p>
 * To reduce the confidence interval by half, one have to execute the
 * experiments 4 more times. This is called the "Replication Method" and
 * just works when the samples are i.i.d. (independent and identically
 * distributed). Thus, if you have correlation between samples of each
 * simulation run, a different method such as a bias compensation,
 * {@link #isApplyBatchMeansMethod() batch means} or regenerative method has
 * to be used. </p>
 *
 * <b>NOTE:</b> How to compute the error margin is a little bit confusing.
 * The Harry Perros' book states that if less than 30 samples are collected,
 * the t-Distribution has to be used to that purpose.
 *
 * However, this article
 * <a href="https://en.wikipedia.org/wiki/Confidence_interval#Basic_Steps">Wikipedia
 * article</a>
 * says that if the standard deviation of the real population is known, it
 * has to be used the z-value from the Standard Normal Distribution.
 * Otherwise, it has to be used the t-value from the t-Distribution to
 * calculate the critical value for defining the error margin (also called
 * standard error). The book "Numeric Computation and Statistical Data
 * Analysis on the Java Platform" confirms the last statement and such
 * approach was followed.
 *
 * @param stats the statistic object with the values to compute the error
 * margin of the confidence interval
 * @param confidenceLevel the confidence level, in the interval from ]0 to
 * 1[, such as 0.95 to indicate 95% of confidence.
 * @return the error margin to compute the lower and upper bound of the
 * confidence interval
 *
 * @see
 * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3672.htm">Critical
 * Values of the Student's t Distribution</a>
 * @see
 * <a href="https://en.wikipedia.org/wiki/Student%27s_t-distribution">t-Distribution</a>
 * @see <a href="http://www4.ncsu.edu/~hp/files/simulation.pdf">Harry
 * Perros, "Computer Simulation Techniques: The definitive introduction!,"
 * 2009</a>
 * @see <a href="http://www.springer.com/gp/book/9783319285290">Numeric
 * Computation and Statistical Data Analysis on the Java Platform</a>
 */
protected double computeConfidenceErrorMargin(SummaryStatistics stats, double confidenceLevel) {
    try {
        // Creates a T-Distribution with N-1 degrees of freedom
        final double degreesOfFreedom = stats.getN() - 1;

        /*
  The t-Distribution is used to determine the probability that
  the real population mean lies in a given interval.
         */
        final TDistribution tDist = new TDistribution(degreesOfFreedom);
        final double significance = 1.0 - confidenceLevel;
        final double criticalValue = tDist.inverseCumulativeProbability(1.0 - significance / 2.0);
        System.out.printf("\n\tt-Distribution critical value for %d samples: %f\n", stats.getN(), criticalValue);

        // Calculates the confidence interval error margin
        return criticalValue * stats.getStandardDeviation() / Math.sqrt(stats.getN());
    } catch (MathIllegalArgumentException e) {
        return Double.NaN;
    }
}
 
开发者ID:manoelcampos,项目名称:cloudsim-plus,代码行数:71,代码来源:ExperimentRunner.java

示例11: get95PercentConfidence

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
public static double get95PercentConfidence(int degreesOfFreedom) {
	TDistribution dist = new TDistribution(degreesOfFreedom);

	return dist.inverseCumulativeProbability(1.0 - 0.05 / 2.0);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:6,代码来源:MathUtils.java

示例12: getSlopeConfidenceInterval

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
/**
 * Returns the half-width of a (100-100*alpha)% confidence interval for
 * the slope estimate.
 * <p>
 * The (100-100*alpha)% confidence interval is </p>
 * <p>
 * <code>(getSlope() - getSlopeConfidenceInterval(),
 * getSlope() + getSlopeConfidenceInterval())</code></p>
 * <p>
 * To request, for example, a 99% confidence interval, use
 * <code>alpha = .01</code></p>
 * <p>
 * <strong>Usage Note</strong>:<br>
 * The validity of this statistic depends on the assumption that the
 * observations included in the model are drawn from a
 * <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html">
 * Bivariate Normal Distribution</a>.</p>
 * <p>
 * <strong> Preconditions:</strong><ul>
 * <li>If there are fewer that <strong>three</strong> observations in the
 * model, or if there is no variation in x, this returns
 * <code>Double.NaN</code>.
 * </li>
 * <li><code>(0 < alpha < 1)</code>; otherwise an
 * <code>OutOfRangeException</code> is thrown.
 * </li></ul></p>
 *
 * @param alpha the desired significance level
 * @return half-width of 95% confidence interval for the slope estimate
 * @throws OutOfRangeException if the confidence interval can not be computed.
 */
public double getSlopeConfidenceInterval(final double alpha)
throws OutOfRangeException {
    if (n < 3) {
        return Double.NaN;
    }
    if (alpha >= 1 || alpha <= 0) {
        throw new OutOfRangeException(LocalizedFormats.SIGNIFICANCE_LEVEL,
                                      alpha, 0, 1);
    }
    // No advertised NotStrictlyPositiveException here - will return NaN above
    TDistribution distribution = new TDistribution(n - 2);
    return getSlopeStdErr() *
        distribution.inverseCumulativeProbability(1d - alpha / 2d);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:46,代码来源:SimpleRegression.java

示例13: getSlopeConfidenceInterval

import org.apache.commons.math3.distribution.TDistribution; //导入方法依赖的package包/类
/**
 * Returns the half-width of a (100-100*alpha)% confidence interval for
 * the slope estimate.
 * <p>
 * The (100-100*alpha)% confidence interval is </p>
 * <p>
 * <code>(getSlope() - getSlopeConfidenceInterval(),
 * getSlope() + getSlopeConfidenceInterval())</code></p>
 * <p>
 * To request, for example, a 99% confidence interval, use
 * <code>alpha = .01</code></p>
 * <p>
 * <strong>Usage Note</strong>:<br>
 * The validity of this statistic depends on the assumption that the
 * observations included in the model are drawn from a
 * <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html">
 * Bivariate Normal Distribution</a>.</p>
 * <p>
 * <strong> Preconditions:</strong><ul>
 * <li>If there are fewer that <strong>three</strong> observations in the
 * model, or if there is no variation in x, this returns
 * <code>Double.NaN</code>.
 * </li>
 * <li><code>(0 < alpha < 1)</code>; otherwise an
 * <code>OutOfRangeException</code> is thrown.
 * </li></ul></p>
 *
 * @param alpha the desired significance level
 * @return half-width of 95% confidence interval for the slope estimate
 * @throws OutOfRangeException if the confidence interval can not be computed.
 */
public double getSlopeConfidenceInterval(final double alpha) {
    if (alpha >= 1 || alpha <= 0) {
        throw new OutOfRangeException(LocalizedFormats.SIGNIFICANCE_LEVEL,
                                      alpha, 0, 1);
    }
    TDistribution distribution = new TDistribution(n - 2);
    return getSlopeStdErr() *
        distribution.inverseCumulativeProbability(1d - alpha / 2d);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:41,代码来源:SimpleRegression.java


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