final FDistribution fdist = new FDistribution(null, a.dfbg, a.dfwg); return 1.0 - fdist.cumulativeProbability(a.F);
/** * used by {@link #getNumericalVariance()} * * @return the variance of this distribution */ protected double calculateNumericalVariance() { final double denominatorDF = getDenominatorDegreesOfFreedom(); if (denominatorDF > 4) { final double numeratorDF = getNumeratorDegreesOfFreedom(); final double denomDFMinusTwo = denominatorDF - 2; return ( 2 * (denominatorDF * denominatorDF) * (numeratorDF + denominatorDF - 2) ) / ( (numeratorDF * (denomDFMinusTwo * denomDFMinusTwo) * (denominatorDF - 4)) ); } return Double.NaN; }
/** {@inheritDoc} */ public ConfidenceInterval createInterval(int numberOfTrials, int numberOfSuccesses, double confidenceLevel) { IntervalUtils.checkParameters(numberOfTrials, numberOfSuccesses, confidenceLevel); double lowerBound = 0; double upperBound = 0; final double alpha = (1.0 - confidenceLevel) / 2.0; final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1), 2 * numberOfSuccesses); final double fValueLowerBound = distributionLowerBound.inverseCumulativeProbability(1 - alpha); if (numberOfSuccesses > 0) { lowerBound = numberOfSuccesses / (numberOfSuccesses + (numberOfTrials - numberOfSuccesses + 1) * fValueLowerBound); } final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1), 2 * (numberOfTrials - numberOfSuccesses)); final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1 - alpha); if (numberOfSuccesses > 0) { upperBound = (numberOfSuccesses + 1) * fValueUpperBound / (numberOfTrials - numberOfSuccesses + (numberOfSuccesses + 1) * fValueUpperBound); } return new ConfidenceInterval(lowerBound, upperBound, confidenceLevel); }
/** * Generates a random value from the {@link FDistribution F Distribution}. * * @param numeratorDf the numerator degrees of freedom of the F distribution * @param denominatorDf the denominator degrees of freedom of the F distribution * @return random value sampled from the F(numeratorDf, denominatorDf) distribution * @throws NotStrictlyPositiveException if * {@code numeratorDf <= 0} or {@code denominatorDf <= 0}. */ public double nextF(double numeratorDf, double denominatorDf) throws NotStrictlyPositiveException { return new FDistribution(getRandomGenerator(), numeratorDf, denominatorDf, FDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample(); }
/** * @param param * degrees of freedom (numerator) * @param param2 * degrees of freedom (denominator) * @return F-distribution */ protected FDistribution getFDistribution(double param, double param2) { if (f == null || f.getDenominatorDegreesOfFreedom() != param2 || f.getNumeratorDegreesOfFreedom() != param) { f = new FDistribution(param, param2); } return f; }
public RealDistribution getRealDistribution(Context context) { RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator(); double e1 = getExpressions().get(0).evaluate(context); double e2 = getExpressions().get(1).evaluate(context); return new FDistribution(randomGenerator, e1, e2); } };
/** * {@inheritDoc} * * For denominator degrees of freedom parameter {@code b}, the mean is * <ul> * <li>if {@code b > 2} then {@code b / (b - 2)},</li> * <li>else undefined ({@code Double.NaN}). * </ul> */ public double getNumericalMean() { final double denominatorDF = getDenominatorDegreesOfFreedom(); if (denominatorDF > 2) { return denominatorDF / (denominatorDF - 2); } return Double.NaN; }
/** * {@inheritDoc} * * @since 2.1 */ public double density(double x) { return FastMath.exp(logDensity(x)); }
/** * {@inheritDoc} * * For numerator degrees of freedom parameter {@code a} and denominator * degrees of freedom parameter {@code b}, the variance is * <ul> * <li> * if {@code b > 4} then * {@code [2 * b^2 * (a + b - 2)] / [a * (b - 2)^2 * (b - 4)]}, * </li> * <li>else undefined ({@code Double.NaN}). * </ul> */ public double getNumericalVariance() { if (!numericalVarianceIsCalculated) { numericalVariance = calculateNumericalVariance(); numericalVarianceIsCalculated = true; } return numericalVariance; }
@Override public final void compute() { if (input[0].isDefined() && input[1].isDefined() && input[2].isDefined()) { double param = a.getDouble(); double param2 = b.getDouble(); double val = c.getDouble(); try { FDistribution dist = getFDistribution(param, param2); num.setValue(dist.inverseCumulativeProbability(val)); // P(T <= // val) } catch (Exception e) { e.printStackTrace(); num.setUndefined(); } } else { num.setUndefined(); } }
/** * Generates a random value from the {@link FDistribution F Distribution}. * * @param numeratorDf the numerator degrees of freedom of the F distribution * @param denominatorDf the denominator degrees of freedom of the F distribution * @return random value sampled from the F(numeratorDf, denominatorDf) distribution * @throws NotStrictlyPositiveException if * {@code numeratorDf <= 0} or {@code denominatorDf <= 0}. */ public double nextF(double numeratorDf, double denominatorDf) throws NotStrictlyPositiveException { return new FDistribution(getRandomGenerator(), numeratorDf, denominatorDf, FDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample(); }
param1 = d1; param2 = d2; sampler = new ContinuousSampler(new FDistribution(d1, d2)); break; default:
/** * {@inheritDoc} * * For denominator degrees of freedom parameter {@code b}, the mean is * <ul> * <li>if {@code b > 2} then {@code b / (b - 2)},</li> * <li>else undefined ({@code Double.NaN}). * </ul> */ public double getNumericalMean() { final double denominatorDF = getDenominatorDegreesOfFreedom(); if (denominatorDF > 2) { return denominatorDF / (denominatorDF - 2); } return Double.NaN; }
/** * {@inheritDoc} * * @since 2.1 */ public double density(double x) { return Math.exp(logDensity(x)); }
/** * {@inheritDoc} * * For numerator degrees of freedom parameter {@code a} and denominator * degrees of freedom parameter {@code b}, the variance is * <ul> * <li> * if {@code b > 4} then * {@code [2 * b^2 * (a + b - 2)] / [a * (b - 2)^2 * (b - 4)]}, * </li> * <li>else undefined ({@code Double.NaN}). * </ul> */ public double getNumericalVariance() { if (!numericalVarianceIsCalculated) { numericalVariance = calculateNumericalVariance(); numericalVarianceIsCalculated = true; } return numericalVariance; }
final FDistribution fdist = new FDistribution(null, a.dfbg, a.dfwg); return 1.0 - fdist.cumulativeProbability(a.F);
public double[] confidenceInterval(){ double N=sampleSize; double nI = numberOfVariables; double df1=N-1.0; double df2=(N-1.0)*(nI-1.0); double[] ci=new double[2]; FDistribution fDist = new FDistribution(df1, df2); try{ ci[0] = 1.0-((1.0-reliability.value())*fDist.inverseCumulativeProbability(0.975)); ci[1] = 1.0-((1.0-reliability.value())*fDist.inverseCumulativeProbability(0.025)); }catch(Exception ex){ ci[0] = Double.NaN; ci[1] = Double.NaN; } return ci; }
/** * Generates a random value from the {@link FDistribution F Distribution}. * * @param numeratorDf the numerator degrees of freedom of the F distribution * @param denominatorDf the denominator degrees of freedom of the F distribution * @return random value sampled from the F(numeratorDf, denominatorDf) distribution * @throws NotStrictlyPositiveException if * {@code numeratorDf <= 0} or {@code denominatorDf <= 0}. */ public double nextF(double numeratorDf, double denominatorDf) throws NotStrictlyPositiveException { return new FDistribution(getRandomGenerator(), numeratorDf, denominatorDf, FDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample(); }
/** * used by {@link #getNumericalVariance()} * * @return the variance of this distribution */ protected double calculateNumericalVariance() { final double denominatorDF = getDenominatorDegreesOfFreedom(); if (denominatorDF > 4) { final double numeratorDF = getNumeratorDegreesOfFreedom(); final double denomDFMinusTwo = denominatorDF - 2; return ( 2 * (denominatorDF * denominatorDF) * (numeratorDF + denominatorDF - 2) ) / ( (numeratorDF * (denomDFMinusTwo * denomDFMinusTwo) * (denominatorDF - 4)) ); } return Double.NaN; }
return new ExponentialDistribution(node.get("mean").asDouble()); case "FDistribution": return new FDistribution(node.get("numeratorDof").asDouble(), node.get("denominatorDof").asDouble()); case "GammaDistribution": return new GammaDistribution(node.get("shape").asDouble(), node.get("scale").asDouble());