Example usage for org.apache.commons.math3.stat.descriptive SummaryStatistics getSumsq

List of usage examples for org.apache.commons.math3.stat.descriptive SummaryStatistics getSumsq

Introduction

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

Prototype

public double getSumsq() 

Source Link

Document

Returns the sum of the squares of the values that have been added.

Usage

From source file:edu.washington.gs.skyline.model.quantification.RegressionFit.java

public Double computeRSquared(CalibrationCurve curve, List<WeightedObservedPoint> points) {
    SummaryStatistics yValues = new SummaryStatistics();
    SummaryStatistics residuals = new SummaryStatistics();
    for (WeightedObservedPoint point : points) {
        Double yFitted = curve.getY(point.getX());
        if (yFitted == null) {
            continue;
        }/*from   w  w  w.  j  a  v  a 2 s  .c om*/
        yValues.addValue(point.getY());
        residuals.addValue(point.getY() - yFitted);
    }
    if (0 == residuals.getN()) {
        return null;
    }
    double yMean = yValues.getMean();
    double totalSumOfSquares = points.stream().mapToDouble(p -> (p.getY() - yMean) * (p.getY() - yMean)).sum();
    double sumOfSquaresOfResiduals = residuals.getSumsq();
    double rSquared = 1 - sumOfSquaresOfResiduals / totalSumOfSquares;
    return rSquared;
}

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

/**
 * Returns true iff <code>object</code> is a
 * <code>SummaryStatistics</code> instance and all statistics have the
 * same values as this./* ww w .  j  a  v  a2 s  .c o m*/
 * @param object the object to test equality against.
 * @return true if object equals this
 */
@Override
public boolean equals(Object object) {
    if (object == this) {
        return true;
    }
    if (object instanceof SummaryStatistics == false) {
        return false;
    }
    SummaryStatistics stat = (SummaryStatistics) object;
    return Precision.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean())
            && Precision.equalsIncludingNaN(stat.getMax(), getMax())
            && Precision.equalsIncludingNaN(stat.getMean(), getMean())
            && Precision.equalsIncludingNaN(stat.getMin(), getMin())
            && Precision.equalsIncludingNaN(stat.getN(), getN())
            && Precision.equalsIncludingNaN(stat.getSum(), getSum())
            && Precision.equalsIncludingNaN(stat.getSumsq(), getSumsq())
            && Precision.equalsIncludingNaN(stat.getVariance(), getVariance());
}

From source file:org.lightjason.agentspeak.action.buildin.math.statistic.EStatisticValue.java

/**
 * returns a statistic value//from w w  w . j a  v  a 2  s .c  om
 *
 * @param p_statistic statistic object
 * @return statistic value
 */
public final double value(final SummaryStatistics p_statistic) {
    switch (this) {
    case GEOMETRICMEAN:
        return p_statistic.getGeometricMean();

    case MAX:
        return p_statistic.getMax();

    case MIN:
        return p_statistic.getMin();

    case COUNT:
        return p_statistic.getN();

    case POPULATIONVARIANCE:
        return p_statistic.getPopulationVariance();

    case QUADRATICMEAN:
        return p_statistic.getQuadraticMean();

    case SECONDMOMENT:
        return p_statistic.getSecondMoment();

    case STANDARDDEVIATION:
        return p_statistic.getStandardDeviation();

    case SUM:
        return p_statistic.getSum();

    case SUMLOG:
        return p_statistic.getSumOfLogs();

    case SUMSQUARE:
        return p_statistic.getSumsq();

    case VARIANCE:
        return p_statistic.getVariance();

    case MEAN:
        return p_statistic.getMean();

    default:
        throw new CIllegalStateException(
                org.lightjason.agentspeak.common.CCommon.languagestring(this, "unknown", this));
    }
}

From source file:org.lightjason.agentspeak.action.builtin.math.statistic.EStatisticValue.java

/**
 * returns a statistic value/*from w  w w  . j av a2  s .c o m*/
 *
 * @param p_statistic statistic object
 * @return statistic value
 */
public final double value(@Nonnull final SummaryStatistics p_statistic) {
    switch (this) {
    case GEOMETRICMEAN:
        return p_statistic.getGeometricMean();

    case MAX:
        return p_statistic.getMax();

    case MIN:
        return p_statistic.getMin();

    case COUNT:
        return p_statistic.getN();

    case POPULATIONVARIANCE:
        return p_statistic.getPopulationVariance();

    case QUADRATICMEAN:
        return p_statistic.getQuadraticMean();

    case SECONDMOMENT:
        return p_statistic.getSecondMoment();

    case STANDARDDEVIATION:
        return p_statistic.getStandardDeviation();

    case SUM:
        return p_statistic.getSum();

    case SUMLOG:
        return p_statistic.getSumOfLogs();

    case SUMSQUARE:
        return p_statistic.getSumsq();

    case VARIANCE:
        return p_statistic.getVariance();

    case MEAN:
        return p_statistic.getMean();

    default:
        throw new CIllegalStateException(
                org.lightjason.agentspeak.common.CCommon.languagestring(this, "unknown", this));
    }
}

From source file:tech.tablesaw.columns.numbers.Stats.java

private static Stats getStats(NumericColumn<?> values, SummaryStatistics summaryStatistics) {
    Stats stats = new Stats("Column: " + values.name());
    stats.min = summaryStatistics.getMin();
    stats.max = summaryStatistics.getMax();
    stats.n = summaryStatistics.getN();/*from  w  ww . j  av  a  2s. co m*/
    stats.sum = summaryStatistics.getSum();
    stats.variance = summaryStatistics.getVariance();
    stats.populationVariance = summaryStatistics.getPopulationVariance();
    stats.quadraticMean = summaryStatistics.getQuadraticMean();
    stats.geometricMean = summaryStatistics.getGeometricMean();
    stats.mean = summaryStatistics.getMean();
    stats.standardDeviation = summaryStatistics.getStandardDeviation();
    stats.sumOfLogs = summaryStatistics.getSumOfLogs();
    stats.sumOfSquares = summaryStatistics.getSumsq();
    stats.secondMoment = summaryStatistics.getSecondMoment();
    return stats;
}