Package org.apache.commons.math.distribution

Examples of org.apache.commons.math.distribution.TDistributionImpl


    /**
     * Verify that direct t-tests using standard error estimates are consistent
     * with reported p-values
     */
    public void testStdErrorConsistency() throws Exception {
        TDistribution tDistribution = new TDistributionImpl(45);
        RealMatrix matrix = createRealMatrix(swissData, 47, 5);
        PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix);
        RealMatrix rValues = corrInstance.getCorrelationMatrix();
        RealMatrix pValues = corrInstance.getCorrelationPValues();
        RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors();
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < i; j++) {
                double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j);
                double p = 2 * (1 - tDistribution.cumulativeProbability(t));
                assertEquals(p, pValues.getEntry(i, j), 10E-15);
            }
        }
    }
View Full Code Here


    return q(new ExponentialDistributionImpl(mean), p, lowerTail, logP);
  }

  @DataParallel @Internal
  public static double dt(@Recycle double x, @Recycle double df, boolean log) {
    return d(new TDistributionImpl(df), x, log);
  }
View Full Code Here

    return StudentsT.dnt(x, df, ncp, log);
  }

  @DataParallel @Internal
  public static double pt(@Recycle double q, @Recycle double df, boolean lowerTail, boolean logP) {
    return p(new TDistributionImpl(df), q, lowerTail, logP);
  }
View Full Code Here

    return StudentsT.pnt(q, df, ncp, lowerTail, logP);
  }

  @DataParallel @Internal
  public static double qt(@Recycle double p, @Recycle double df, boolean lowerTail, boolean logP) {
    return q(new TDistributionImpl(df), p, lowerTail, logP);
  }
View Full Code Here

    /**
     * Create an empty SimpleRegression instance
     */
    public SimpleRegression() {
        this(new TDistributionImpl(1.0));
    }
View Full Code Here

     * @param degrees Number of degrees of freedom of the distribution
     * used to compute inference statistics.
     * @since 2.2
     */
    public SimpleRegression(int degrees) {
        setDistribution(new TDistributionImpl(degrees));
    }
View Full Code Here

    /**
     * Default constructor.
     */
    public TTestImpl() {
        this(new TDistributionImpl(1.0));
    }
View Full Code Here

     * @return random value from the T(df) distribution
     * @throws MathException if an error occurs generating the random value
     * @since 2.2
     */
    public double nextT(double df) throws MathException {
        return nextInversionDeviate(new TDistributionImpl(df));
    }
View Full Code Here

     *
     * @return matrix of p-values
     * @throws MathException if an error occurs estimating probabilities
     */
    public RealMatrix getCorrelationPValues() throws MathException {
        TDistribution tDistribution = new TDistributionImpl(nObs - 2);
        int nVars = correlationMatrix.getColumnDimension();
        double[][] out = new double[nVars][nVars];
        for (int i = 0; i < nVars; i++) {
            for (int j = 0; j < nVars; j++) {
                if (i == j) {
                    out[i][j] = 0d;
                } else {
                    double r = correlationMatrix.getEntry(i, j);
                    double t = FastMath.abs(r * FastMath.sqrt((nObs - 2)/(1 - r * r)));
                    out[i][j] = 2 * tDistribution.cumulativeProbability(-t);
                }
            }
        }
        return new BlockRealMatrix(out);
    }
View Full Code Here

   
    /**
     * Default constructor.
     */
    public TTestImpl() {
        this(new TDistributionImpl(1.0));
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.distribution.TDistributionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.