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

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

Introduction

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

Prototype

public double getMax() 

Source Link

Document

Returns the maximum of the values that have been added.

Usage

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

/**
 * returns a statistic value// w  w  w .  ja va2 s.co  m
 *
 * @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  a  v  a 2  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:org.orbisgis.corejdbc.ReadTable.java

/**
 * Compute numeric stats of the specified table column using a limited input rows. Stats are not done in the sql side.
 * @param connection Available connection
 * @param tableName Table name/*  w  w w.j  av  a2 s  . c  om*/
 * @param columnName Column name
 * @param rowNum Row id
 * @param pm Progress monitor
 * @return An array of attributes {@link STATS}
 * @throws SQLException
 */
public static String[] computeStatsLocal(Connection connection, String tableName, String columnName,
        SortedSet<Integer> rowNum, ProgressMonitor pm) throws SQLException {
    String[] res = new String[STATS.values().length];
    SummaryStatistics stats = new SummaryStatistics();
    try (Statement st = connection.createStatement()) {
        // Cancel select
        PropertyChangeListener listener = EventHandler.create(PropertyChangeListener.class, st, "cancel");
        pm.addPropertyChangeListener(ProgressMonitor.PROP_CANCEL, listener);
        try (ResultSet rs = st.executeQuery(String.format("SELECT %s FROM %s", columnName, tableName))) {
            ProgressMonitor fetchProgress = pm.startTask(rowNum.size());
            while (rs.next() && !pm.isCancelled()) {
                if (rowNum.contains(rs.getRow())) {
                    stats.addValue(rs.getDouble(columnName));
                    fetchProgress.endTask();
                }
            }
        } finally {
            pm.removePropertyChangeListener(listener);
        }
    }
    res[STATS.SUM.ordinal()] = Double.toString(stats.getSum());
    res[STATS.AVG.ordinal()] = Double.toString(stats.getMean());
    res[STATS.COUNT.ordinal()] = Long.toString(stats.getN());
    res[STATS.MIN.ordinal()] = Double.toString(stats.getMin());
    res[STATS.MAX.ordinal()] = Double.toString(stats.getMax());
    res[STATS.STDDEV_SAMP.ordinal()] = Double.toString(stats.getStandardDeviation());
    return res;
}

From source file:org.orekit.forces.gravity.SolidTidesFieldTest.java

@Test
public void testInterpolationAccuracy() throws OrekitException {

    // The shortest periods are slightly below one half day for the tidal waves
    // considered here. This implies the sampling rate should be fast enough.
    // The tuning parameters we have finally settled correspond to a two hours
    // sample containing 12 points (i.e. one new point is computed every 10 minutes).
    // The observed relative interpolation error with these settings are essentially
    // due to Runge phenomenon at points sampling rate. Plotting the errors shows
    // singular peaks pointing out of merely numerical noise.
    final IERSConventions conventions = IERSConventions.IERS_2010;
    Frame itrf = FramesFactory.getITRF(conventions, true);
    TimeScale utc = TimeScalesFactory.getUTC();
    UT1Scale ut1 = TimeScalesFactory.getUT1(conventions, true);
    NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getConstantNormalizedProvider(5, 5);

    SolidTidesField raw = new SolidTidesField(conventions.getLoveNumbers(),
            conventions.getTideFrequencyDependenceFunction(ut1), conventions.getPermanentTide(),
            conventions.getSolidPoleTide(ut1.getEOPHistory()), itrf, gravityField.getAe(), gravityField.getMu(),
            gravityField.getTideSystem(), CelestialBodyFactory.getSun(), CelestialBodyFactory.getMoon());
    int step = 600;
    int nbPoints = 12;
    CachedNormalizedSphericalHarmonicsProvider interpolated = new CachedNormalizedSphericalHarmonicsProvider(
            raw, step, nbPoints, OrekitConfiguration.getCacheSlotsNumber(), 7 * Constants.JULIAN_DAY,
            0.5 * Constants.JULIAN_DAY);

    // the following time range is located around the maximal observed error
    AbsoluteDate start = new AbsoluteDate(2003, 6, 12, utc);
    AbsoluteDate end = start.shiftedBy(3 * Constants.JULIAN_DAY);
    SummaryStatistics stat = new SummaryStatistics();
    for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(60)) {
        NormalizedSphericalHarmonics rawHarmonics = raw.onDate(date);
        NormalizedSphericalHarmonics interpolatedHarmonics = interpolated.onDate(date);

        for (int n = 2; n < 5; ++n) {
            for (int m = 0; m <= n; ++m) {

                if (n < 4 || m < 3) {
                    double cnmRaw = rawHarmonics.getNormalizedCnm(n, m);
                    double cnmInterp = interpolatedHarmonics.getNormalizedCnm(n, m);
                    double errorC = (cnmInterp - cnmRaw) / FastMath.abs(cnmRaw);
                    stat.addValue(errorC);

                    if (m > 0) {
                        double snmRaw = rawHarmonics.getNormalizedSnm(n, m);
                        double snmInterp = interpolatedHarmonics.getNormalizedSnm(n, m);
                        double errorS = (snmInterp - snmRaw) / FastMath.abs(snmRaw);
                        stat.addValue(errorS);
                    }/*from   ww w  .ja  va 2 s .  co  m*/
                }
            }
        }
    }
    Assert.assertEquals(0.0, stat.getMean(), 2.0e-12);
    Assert.assertTrue(stat.getStandardDeviation() < 2.0e-9);
    Assert.assertTrue(stat.getMin() > -9.0e-8);
    Assert.assertTrue(stat.getMax() < 8.0e-8);

}

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 w  w  . j  av a  2s  .  com*/
    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;
}