Example usage for org.apache.commons.math.stat.correlation Covariance Covariance

List of usage examples for org.apache.commons.math.stat.correlation Covariance Covariance

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.correlation Covariance Covariance.

Prototype

public Covariance() 

Source Link

Document

Create a Covariance with no data

Usage

From source file:com.clican.pluto.dataprocess.dpl.function.impl.Convariance.java

public Object calculate(List<Map<String, Object>> rowSet)
        throws CalculationException, PrefixAndSuffixException {
    if (rowSet.size() == 0) {
        throw new CalculationException("Convariance??");
    }//from   w  ww.  j  a v a2  s .c o m
    double[] estimateValueList = new double[rowSet.size()];
    double[] referValueList = new double[rowSet.size()];
    for (int i = 0; i < rowSet.size(); i++) {
        Map<String, Object> row = rowSet.get(i);
        Double estimateValue = estimateVectorPas.getValue(row);
        Double referValue = referVectorPas.getValue(row);
        estimateValueList[i] = estimateValue;
        referValueList[i] = referValue;
    }
    Covariance cov = new Covariance();
    double covValue = cov.covariance(referValueList, estimateValueList, false);
    return covValue;
}

From source file:com.clican.pluto.dataprocess.dpl.function.impl.Beta.java

private double getBeta(double[] referValueList, double[] estimateValueList) {
    Variance var = new Variance(false);
    Covariance cov = new Covariance();
    double varValue = var.evaluate(referValueList);
    double covValue = cov.covariance(referValueList, estimateValueList, false);
    if (log.isDebugEnabled()) {
        log.debug("Covariance=[" + covValue + "],Variance=[" + varValue + "]");
    }//from  ww w . j  ava  2s. c  o  m
    Double beta = covValue / varValue;
    return beta;
}

From source file:com.srotya.sidewinder.core.analytics.TestMathUtils.java

@Test
public void testCovariance() {
    double[] a = new double[] { 2, 3, 4, 5, 6 };
    double[] b = new double[] { 2.2, 33.2, 44.4, 55.5, 66.6 };
    Covariance cov = new Covariance();
    double covariance = cov.covariance(a, b, false);
    double amean = MathUtils.mean(a);
    double bmean = MathUtils.mean(b);
    assertEquals(covariance, MathUtils.covariance(a, amean, b, bmean), 0.001);
}

From source file:org.rascalmpl.library.analysis.statistics.Correlations.java

public IValue covariance(IList dataValues) {
    make(dataValues);
    return values.real(new Covariance().covariance(xvalues, yvalues, false));
}