List of usage examples for org.apache.commons.math3.distribution TDistribution inverseCumulativeProbability
public double inverseCumulativeProbability(final double p) throws OutOfRangeException
From source file:tinfour.gwr.SurfaceGwr.java
/** * Gets a value equal to one half of the range of the prediction interval * on the observed response at the interpolation coordinates for the * most recent call to computeRegression(). * * @param alpha the significance level (typically 0..05, etc). * @return a positive value./*from w ww . j a v a 2 s. c o m*/ */ public double getPredictionIntervalHalfRange(double alpha) { // TO DO: if the method is OLS, it would make sense to // use a OLS version of this calculation rather than // the more costly Leung version... Also, I am not 100 % // sure that they converge to the same answer, though they should computeVarianceAndHat(); //double effDegOfF = getEffectiveDegreesOfFreedom(); // should match delta1 double[][] input = computeDesignMatrix(model, xOffset, yOffset, nSamples, samples); RealMatrix mX = new BlockRealMatrix(input); RealMatrix mXT = mX.transpose(); // the weights array may not necessarily be of dimension nSamples, // so we need to copy it double[] rW = Arrays.copyOf(weights, nSamples); RealMatrix mW = new DiagonalMatrix(rW); RealMatrix design = mXT.multiply(mW).multiply(mX); RealMatrix vcm; try { QRDecomposition cd = new QRDecomposition(design); DecompositionSolver s = cd.getSolver(); vcm = s.getInverse(); } catch (SingularMatrixException npex) { return Double.NaN; } double nLeungDOF = (delta1 * delta1 / delta2); for (int i = 0; i < nSamples; i++) { rW[i] = weights[i] * weights[i]; } DiagonalMatrix mW2 = new DiagonalMatrix(rW); RealMatrix mS = vcm.multiply(mXT).multiply(mW2).multiply(mX).multiply(vcm); double pS = mS.getEntry(0, 0); double p = Math.sqrt(this.sigma2 * (1 + pS)); TDistribution td = new TDistribution(nLeungDOF); double ta = td.inverseCumulativeProbability(1.0 - alpha / 2.0); return ta * p; }
From source file:tools.descartes.bungee.evaluation.ScalabilityReproducibilityEvaluation.java
private double getConfidenceIntervalWidth(SummaryStatistics summaryStatistics, double confidence) { double significance = 1 - confidence; TDistribution tDist = new TDistribution(summaryStatistics.getN() - 1); double a = tDist.inverseCumulativeProbability(1.0 - significance / 2); return a * summaryStatistics.getStandardDeviation() / Math.sqrt(summaryStatistics.getN()); }
From source file:UserPerformance.GetLowerBound.java
private static double calcMeanCI(double n, double StandardDeviation, double alfa) { try {/*from ww w . j a va 2s . c om*/ // Create T Distribution with N-1 degrees of freedom TDistribution tDist = new TDistribution(n - 1); // Calculate critical value double critVal = tDist.inverseCumulativeProbability(1.0 - (1 - alfa) / 2); // Calculate confidence interval return (critVal * StandardDeviation / Math.sqrt(n)); } catch (MathIllegalArgumentException e) { return Double.NaN; } }
From source file:wsattacker.plugin.intelligentdos.StatisticTest.java
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()); }