Java Code Examples for org.apache.commons.math.stat.descriptive.moment.SecondMoment

The following examples show how to use org.apache.commons.math.stat.descriptive.moment.SecondMoment. 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
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 2
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 3
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 4
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 5
@Test
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        Assert.assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        Assert.assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 6
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 7
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 8
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 9
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 10
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 11
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 12
@Test
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        Assert.assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        Assert.assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 13
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 14
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 15
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 16
Source Project: astor   Source File: SummaryStatisticsImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a SummaryStatistics
 */
public SummaryStatisticsImpl() {
    sum = new Sum();
    sumsq = new SumOfSquares();
    min = new Min();
    max = new Max();
    sumLog = new SumOfLogs();
    geoMean = new GeometricMean();
    secondMoment = new SecondMoment();
}
 
Example 17
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 18
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 19
public void testMomentSmallSamples() {
    UnivariateStatistic stat = getUnivariateStatistic();
    if (stat instanceof SecondMoment) {
        SecondMoment moment = (SecondMoment) getUnivariateStatistic();
        assertTrue(Double.isNaN(moment.getResult()));
        moment.increment(1d);
        assertEquals(0d, moment.getResult(), 0);
    }
}
 
Example 20
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 21
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 22
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 23
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullArgumentException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest)
    throws NullArgumentException {
    MathUtils.checkNotNull(source);
    MathUtils.checkNotNull(dest);
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 24
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 25
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 26
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 27
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 28
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 29
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullPointerException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}
 
Example 30
Source Project: astor   Source File: SummaryStatistics.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Copies source to dest.
 * <p>Neither source nor dest can be null.</p>
 *
 * @param source SummaryStatistics to copy
 * @param dest SummaryStatistics to copy to
 * @throws NullArgumentException if either source or dest is null
 */
public static void copy(SummaryStatistics source, SummaryStatistics dest)
    throws NullArgumentException {
    MathUtils.checkNotNull(source);
    MathUtils.checkNotNull(dest);
    dest.maxImpl = source.maxImpl.copy();
    dest.meanImpl = source.meanImpl.copy();
    dest.minImpl = source.minImpl.copy();
    dest.sumImpl = source.sumImpl.copy();
    dest.varianceImpl = source.varianceImpl.copy();
    dest.sumLogImpl = source.sumLogImpl.copy();
    dest.sumsqImpl = source.sumsqImpl.copy();
    if (source.getGeoMeanImpl() instanceof GeometricMean) {
        // Keep geoMeanImpl, sumLogImpl in synch
        dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
    } else {
        dest.geoMeanImpl = source.geoMeanImpl.copy();
    }
    SecondMoment.copy(source.secondMoment, dest.secondMoment);
    dest.n = source.n;

    // Make sure that if stat == statImpl in source, same
    // holds in dest; otherwise copy stat
    if (source.geoMean == source.geoMeanImpl) {
        dest.geoMean = (GeometricMean) dest.geoMeanImpl;
    } else {
        GeometricMean.copy(source.geoMean, dest.geoMean);
    }
    if (source.max == source.maxImpl) {
        dest.max = (Max) dest.maxImpl;
    } else {
        Max.copy(source.max, dest.max);
    }
    if (source.mean == source.meanImpl) {
        dest.mean = (Mean) dest.meanImpl;
    } else {
        Mean.copy(source.mean, dest.mean);
    }
    if (source.min == source.minImpl) {
        dest.min = (Min) dest.minImpl;
    } else {
        Min.copy(source.min, dest.min);
    }
    if (source.sum == source.sumImpl) {
        dest.sum = (Sum) dest.sumImpl;
    } else {
        Sum.copy(source.sum, dest.sum);
    }
    if (source.variance == source.varianceImpl) {
        dest.variance = (Variance) dest.varianceImpl;
    } else {
        Variance.copy(source.variance, dest.variance);
    }
    if (source.sumLog == source.sumLogImpl) {
        dest.sumLog = (SumOfLogs) dest.sumLogImpl;
    } else {
        SumOfLogs.copy(source.sumLog, dest.sumLog);
    }
    if (source.sumsq == source.sumsqImpl) {
        dest.sumsq = (SumOfSquares) dest.sumsqImpl;
    } else {
        SumOfSquares.copy(source.sumsq, dest.sumsq);
    }
}