Example usage for org.apache.commons.math3.stat.descriptive.moment Variance Variance

List of usage examples for org.apache.commons.math3.stat.descriptive.moment Variance Variance

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.descriptive.moment Variance Variance.

Prototype

public Variance(Variance original) throws NullArgumentException 

Source Link

Document

Copy constructor, creates a new Variance identical to the original

Usage

From source file:cz.cuni.mff.d3s.spl.utils.StatisticsUtils.java

/** Compute variance of given data without bias correction.
 * /* www . j  a va  2  s .  co m*/
 * @param values Array of values to compute the variance from.
 * @return Varince of the provided values.
 */
public static double varianceN(double... values) {
    Variance var = new Variance(false);
    return var.evaluate(values);
}

From source file:com.itemanalysis.psychometrics.rasch.ScaleQualityStatistics.java

public ScaleQualityStatistics() {
    var = new Variance(false);
    mean = new Mean();
}

From source file:com.itemanalysis.psychometrics.irt.estimation.RaschScaleQualityStatistics.java

public RaschScaleQualityStatistics() {
    var = new Variance(false);
    mean = new Mean();
}

From source file:com.facebook.presto.operator.aggregation.TestDoubleVariancePopAggregation.java

@Override
public Number getExpectedValue(int start, int length) {
    if (length == 0) {
        return null;
    }/*from ww w  .jav  a  2  s. c  o m*/

    double[] values = new double[length];
    for (int i = 0; i < length; i++) {
        values[i] = start + i;
    }

    Variance variance = new Variance(false);
    return variance.evaluate(values);
}

From source file:edu.uiowa.icts.bluebutton.json.view.StatsFinder.java

private SummaryStatistics findStats() {
    SummaryStatistics stats = new SummaryStatistics();
    stats.setVarianceImpl(new Variance(false));
    for (IGetStats d : this.list) {
        if (d.getDoubleValue() != null) {
            stats.addValue(d.getDoubleValue());
        }//  ww  w .j  a v  a 2s . c  o  m
    }
    return stats;
}

From source file:com.std.Index.java

@Override
public void calculate_beta(YStockQuote sp500, int timeFrame) {
    double[] sp500Col = Arrays.copyOfRange(sp500.get_historical_rate_of_return(), 0, timeFrame);
    calculate_historical_rate_of_return(timeFrame);
    sp500Col = Arrays.copyOfRange(sp500.get_historical_rate_of_return(), 0,
            this.historical_rate_of_return.length);
    Covariance covarianceObj = new Covariance();
    Variance varianceObj = new Variance(false);
    double covariance = covarianceObj.covariance(historical_rate_of_return, sp500Col);
    double variance = varianceObj.evaluate(sp500Col);

    this.Beta = String.valueOf(Math.round((covariance / variance) * 100.0) / 100.0);
}

From source file:org.apereo.portal.events.aggr.stat.JpaStatisticalSummary.java

private Variance _getVariance() {
    if (this.variance == null) {
        this.variance = new Variance(this._getSecondMoment());
    }/*from ww  w .  jav  a 2 s.c om*/
    return this.variance;
}

From source file:org.apereo.portal.events.aggr.stat.JpaStatisticalSummary.java

/**
 * Returns the <a href="http://en.wikibooks.org/wiki/Statistics/Summary/Variance">
 * population variance</a> of the values that have been added.
 *
 * <p>Double.NaN is returned if no values have been added.</p>
 *
 * @return the population variance/*from  w ww  .  j av  a 2  s  .  c  o m*/
 */
public double getPopulationVariance() {
    Variance populationVariance = new Variance(_getSecondMoment());
    populationVariance.setBiasCorrected(false);
    return populationVariance.getResult();
}

From source file:ro.hasna.ts.math.representation.PiecewiseLinearAggregateApproximation.java

/**
 * Transform a given sequence of values using the algorithm PLAA.
 *
 * @param values the sequence of values/*from www .  j  av a 2s  .co  m*/
 * @return the result of the transformation
 */
public MeanSlopePair[] transform(double[] values) {
    int len = values.length;
    if (len < segments) {
        throw new ArrayLengthIsTooSmallException(len, segments, true);
    }

    int modulo = len % segments;
    if (modulo != 0) {
        throw new ArrayLengthIsNotDivisibleException(len, segments);
    }

    MeanSlopePair[] reducedValues = new MeanSlopePair[segments];
    int segmentSize = len / segments;

    double[] x = new double[segmentSize];
    for (int i = 0; i < segmentSize; i++) {
        x[i] = i + 1;
    }

    double variance = new Variance(true).evaluate(x);
    for (int i = 0; i < segments; i++) {
        double[] y = new double[segmentSize];
        System.arraycopy(values, i * segmentSize, y, 0, segmentSize);

        double covariance = new Covariance().covariance(x, y, true);
        double mean = new Mean().evaluate(y);

        reducedValues[i] = new MeanSlopePair(mean, covariance / variance);
    }

    return reducedValues;
}

From source file:Rotationforest.Covariance.java

/**
 * Compute a covariance matrix from a matrix whose columns represent
 * covariates./*from  w  ww  . java2  s  .c om*/
 * @param matrix input matrix (must have at least one column and two rows)
 * @param biasCorrected determines whether or not covariance estimates are bias-corrected
 * @return covariance matrix
 * @throws MathIllegalArgumentException if the matrix does not contain sufficient data
 */
protected RealMatrix computeCovarianceMatrix(RealMatrix matrix, boolean biasCorrected)
        throws MathIllegalArgumentException {
    int dimension = matrix.getColumnDimension();
    Variance variance = new Variance(biasCorrected);
    RealMatrix outMatrix = new BlockRealMatrix(dimension, dimension);
    for (int i = 0; i < dimension; i++) {
        for (int j = 0; j < i; j++) {
            double cov = covariance(matrix.getColumn(i), matrix.getColumn(j), biasCorrected);
            outMatrix.setEntry(i, j, cov);
            outMatrix.setEntry(j, i, cov);

        }
        outMatrix.setEntry(i, i, variance.evaluate(matrix.getColumn(i)));
        outMatrix.setEntry(i, i, variance.evaluate(matrix.getColumn(i)));
    }
    //return outMatrix;
    return outMatrix;

}