Java Code Examples for org.apache.commons.math.stat.StatUtils#variance()

The following examples show how to use org.apache.commons.math.stat.StatUtils#variance() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    assertEquals(variance, lower + upper, 10e-12);
}
 
Example 2
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    assertEquals(variance, lower + upper, 10e-12);
}
 
Example 3
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
@Test
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    Assert.assertEquals(variance, lower + upper, 10e-12);
}
 
Example 4
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    assertEquals(variance, lower + upper, 10e-12);
}
 
Example 5
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    assertEquals(variance, lower + upper, 10e-12);
}
 
Example 6
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    assertEquals(variance, lower + upper, 10e-12);
}
 
Example 7
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    assertEquals(variance, lower + upper, 10e-12);
}
 
Example 8
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
@Test
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    Assert.assertEquals(variance, lower + upper, 10e-12);
}
 
Example 9
/**
 * Check that the lower + upper semivariance against the mean sum to the
 * variance.
 */
public void testVarianceDecompMeanCutoff() {
    double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    double variance = StatUtils.variance(values);
    SemiVariance sv = new SemiVariance(true); // Bias corrected
    sv.setVarianceDirection(SemiVariance.DOWNSIDE_VARIANCE);
    final double lower = sv.evaluate(values);
    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upper = sv.evaluate(values);
    assertEquals(variance, lower + upper, 10e-12);
}
 
Example 10
/**
 *
 * @param list
 * @return
 */
public double getVariance(List<SynsetOut> list) {
    double[] scores = new double[list.size()];
    int l = 0;
    for (SynsetOut out : list) {
        scores[l] = out.getScore();
        l++;
    }
    return StatUtils.variance(scores);
}