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

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

Introduction

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

Prototype

public SecondMoment() 

Source Link

Document

Create a SecondMoment instance

Usage

From source file:gamlss.utilities.WLSMultipleLinearRegression.java

/**
* {@inheritDoc}/*from   w  ww  .  j a  v  a2  s.  c o m*/
* Double.NaN is not applicable
*/
@Override
public double calculateTotalSumOfSquares() {
    if (this.copyOriginal) {
        if (isNoIntercept()) {
            return StatUtils.sumSq(this.y.toArray());
        } else {
            return new SecondMoment().evaluate(this.y.toArray());
        }
    }
    return Double.NaN;
}

From source file:org.apereo.portal.events.aggr.JpaStatisticalSummaryTest.java

@Ignore
@Test/*from w ww. ja v  a 2 s.  co m*/
public void testSummaryStatisticsJson() throws Exception {
    final SecondMoment secondMoment = new SecondMoment();
    final Sum sum = new Sum();
    final SumOfSquares sumsq = new SumOfSquares();
    final Min min = new Min();
    final Max max = new Max();
    final SumOfLogs sumLog = new SumOfLogs();

    final Random r = new Random(0);
    for (int i = 0; i < 10; i++) {
        final int nextInt = r.nextInt(100000000);
        secondMoment.increment(nextInt);
        sum.increment(nextInt);
        sumsq.increment(nextInt);
        min.increment(nextInt);
        max.increment(nextInt);
        sumLog.increment(nextInt);
    }

    testStorelessUnivariateStatistic(secondMoment, 7.513432791665536E15);
    testStorelessUnivariateStatistic(sum, 6.01312177E8);
    testStorelessUnivariateStatistic(sumsq, 4.3671066212513456E16);
    testStorelessUnivariateStatistic(min, 2116447.0);
    testStorelessUnivariateStatistic(max, 8.5505948E7);
    testStorelessUnivariateStatistic(sumLog, 175.91713800250577);
}

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

private SecondMoment _getSecondMoment() {
    if (this.secondMoment == null) {
        this.secondMoment = new SecondMoment();
    }/*from w  ww.j a  v  a2 s . c  om*/
    return this.secondMoment;
}

From source file:org.ssascaling.model.timeseries.learner.apache.OLSMultipleLinearRegression.java

/**
 * <p>Returns the sum of squared deviations of Y from its mean.</p>
 *
 * <p>If the model has no intercept term, <code>0</code> is used for the
 * mean of Y - i.e., what is returned is the sum of the squared Y values.</p>
 *
 * <p>The value returned by this method is the SSTO value used in
 * the {@link #calculateRSquared() R-squared} computation.</p>
 *
 * @return SSTO - the total sum of squares
 * @see #isNoIntercept()//w  w  w.  j  a va2  s  . c o m
 * @since 2.2
 */
public double calculateTotalSumOfSquares() {
    if (isNoIntercept()) {
        return StatUtils.sumSq(getY().toArray());
    } else {
        return new SecondMoment().evaluate(getY().toArray());
    }
}