List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getKurtosis
public double getKurtosis()
From source file:org.jenetics.stat.LongMomentStatisticsTest.java
@Test(dataProvider = "parallelSampleCounts") public void parallelSummary(final Integer sampleCounts, final Double epsilon) { final List<Long> numbers = numbers(sampleCounts); final DescriptiveStatistics expected = new DescriptiveStatistics(); numbers.forEach(expected::addValue); final LongMomentStatistics summary = numbers.stream().collect(toLongMomentStatistics(Long::longValue)); Assert.assertEquals(summary.getCount(), numbers.size()); assertEqualsDouble(min(summary.getMin()), expected.getMin(), 0.0); assertEqualsDouble(max(summary.getMax()), expected.getMax(), 0.0); assertEqualsDouble(summary.getSum(), expected.getSum(), epsilon); assertEqualsDouble(summary.getMean(), expected.getMean(), epsilon); assertEqualsDouble(summary.getVariance(), expected.getVariance(), epsilon); assertEqualsDouble(summary.getSkewness(), expected.getSkewness(), epsilon); assertEqualsDouble(summary.getKurtosis(), expected.getKurtosis(), epsilon); }
From source file:org.lightjason.agentspeak.action.buildin.math.statistic.EStatisticValue.java
/** * returns a statistic value//from ww w . j a v a 2 s. co m * * @param p_statistic statistic object * @return statistic value */ public final double value(final DescriptiveStatistics 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 STANDARDDEVIATION: return p_statistic.getStandardDeviation(); case SUM: return p_statistic.getSum(); case SUMSQUARE: return p_statistic.getSumsq(); case VARIANCE: return p_statistic.getVariance(); case MEAN: return p_statistic.getMean(); case KURTIOSIS: return p_statistic.getKurtosis(); 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 a2s. c o m*/ * * @param p_statistic statistic object * @return statistic value */ public final double value(@Nonnull final DescriptiveStatistics 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 STANDARDDEVIATION: return p_statistic.getStandardDeviation(); case SUM: return p_statistic.getSum(); case SUMSQUARE: return p_statistic.getSumsq(); case VARIANCE: return p_statistic.getVariance(); case MEAN: return p_statistic.getMean(); case KURTIOSIS: return p_statistic.getKurtosis(); default: throw new CIllegalStateException( org.lightjason.agentspeak.common.CCommon.languagestring(this, "unknown", this)); } }
From source file:org.moeaframework.core.PRNGTest.java
/** * Asserts that the statistical distribution satisfies the properties of a * real-valued uniform distribution between {@code min} and {@code max}. * // w w w . j a v a2s. com * @param min the minimum bounds of the uniform distribution * @param max the maximum bounds of the uniform distribution * @param statistics the captures statistics of a sampled distribution */ private void testUniformDistribution(double min, double max, DescriptiveStatistics statistics) { Assert.assertEquals((min + max) / 2.0, statistics.getMean(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(Math.pow(max - min, 2.0) / 12.0, statistics.getVariance(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(0.0, statistics.getSkewness(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(-6.0 / 5.0, statistics.getKurtosis(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(min, statistics.getMin(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(max, statistics.getMax(), TestThresholds.STATISTICS_EPS); }
From source file:org.moeaframework.core.PRNGTest.java
/** * Asserts that the statistical distribution satisfies the properties of an * integer-valued uniform distribution between {@code min} and {@code max}. * //from w w w.j av a2 s . c om * @param min the minimum bounds of the uniform distribution * @param max the maximum bounds of the uniform distribution * @param statistics the captures statistics of a sampled distribution */ private void testUniformDistribution(int min, int max, DescriptiveStatistics statistics) { int n = max - min + 1; int nn = n * n; Assert.assertEquals((min + max) / 2.0, statistics.getMean(), TestThresholds.STATISTICS_EPS); Assert.assertEquals((nn - 1) / 12.0, statistics.getVariance(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(0.0, statistics.getSkewness(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(-(6.0 * (nn + 1)) / (5.0 * (nn - 1)), statistics.getKurtosis(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(min, statistics.getMin(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(max, statistics.getMax(), TestThresholds.STATISTICS_EPS); }
From source file:org.moeaframework.core.PRNGTest.java
/** * Asserts that the statistical distribution satisfies the properties of a * Gaussian distribution with the specified mean and standard deviation. * //w ww.j a va2s .c o m * @param mu the mean value of the distribution * @param sigma the standard deviation of the distribution * @param statistics the captures statistics of a sampled distribution */ private void testGaussianDistribution(double mu, double sigma, DescriptiveStatistics statistics) { Assert.assertEquals(mu, statistics.getMean(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(sigma * sigma, statistics.getVariance(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(0.0, statistics.getSkewness(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(0.0, statistics.getKurtosis(), TestThresholds.STATISTICS_EPS); }
From source file:org.moeaframework.TestUtils.java
/** * Asserts that the statistical distribution satisfies the properties of an * integer-valued uniform distribution between {@code min} and {@code max}. * //w w w . j a v a 2 s.c om * @param min the minimum bounds of the uniform distribution * @param max the maximum bounds of the uniform distribution * @param statistics the captures statistics of a sampled distribution */ public static void assertUniformDistribution(int min, int max, DescriptiveStatistics statistics) { int n = max - min + 1; int nn = n * n; assertEquals((min + max) / 2.0, statistics.getMean()); assertEquals((nn - 1) / 12.0, statistics.getVariance()); assertEquals(0.0, statistics.getSkewness()); assertEquals(-(6.0 * (nn + 1)) / (5.0 * (nn - 1)), statistics.getKurtosis()); assertEquals(min, statistics.getMin()); assertEquals(max, statistics.getMax()); }
From source file:org.moeaframework.util.sequence.SequenceTest.java
/** * Asserts that the collected statistics appear to be from a uniform * distribution.// w w w.j av a 2 s .co m * * @param min the minimum value * @param max the maximum value * @param statistics the collected statistics */ public void testUniformDistribution(double min, double max, DescriptiveStatistics statistics) { Assert.assertEquals((min + max) / 2.0, statistics.getMean(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(Math.pow(max - min, 2.0) / 12.0, statistics.getVariance(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(0.0, statistics.getSkewness(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(-6.0 / 5.0, statistics.getKurtosis(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(min, statistics.getMin(), TestThresholds.STATISTICS_EPS); Assert.assertEquals(max, statistics.getMax(), TestThresholds.STATISTICS_EPS); }
From source file:org.obiba.opal.web.magma.Dtos.java
@SuppressWarnings({ "OverlyLongMethod", "PMD.NcssMethodCount" }) public static Math.ContinuousSummaryDto.Builder asDto(ContinuousVariableSummary summary) { DescriptiveStatistics descriptiveStats = summary.getDescriptiveStats(); Math.DescriptiveStatsDto.Builder descriptiveBuilder = Math.DescriptiveStatsDto.newBuilder() .setN(descriptiveStats.getN()).addAllPercentiles(summary.getPercentiles()); if (isNumeric(descriptiveStats.getMin())) descriptiveBuilder.setMin(descriptiveStats.getMin()); if (isNumeric(descriptiveStats.getMax())) descriptiveBuilder.setMax(descriptiveStats.getMax()); if (isNumeric(descriptiveStats.getMean())) descriptiveBuilder.setMean(descriptiveStats.getMean()); if (isNumeric(descriptiveStats.getSum())) descriptiveBuilder.setSum(descriptiveStats.getSum()); if (isNumeric(descriptiveStats.getSumsq())) descriptiveBuilder.setSumsq(descriptiveStats.getSumsq()); if (isNumeric(descriptiveStats.getStandardDeviation())) { descriptiveBuilder.setStdDev(descriptiveStats.getStandardDeviation()); }// w w w . ja v a2s . c o m if (isNumeric(descriptiveStats.getVariance())) descriptiveBuilder.setVariance(descriptiveStats.getVariance()); if (isNumeric(descriptiveStats.getSkewness())) descriptiveBuilder.setSkewness(descriptiveStats.getSkewness()); if (isNumeric(descriptiveStats.getGeometricMean())) { descriptiveBuilder.setGeometricMean(descriptiveStats.getGeometricMean()); } if (isNumeric(descriptiveStats.getKurtosis())) descriptiveBuilder.setKurtosis(descriptiveStats.getKurtosis()); double median = descriptiveStats.apply(new Median()); if (isNumeric(median)) descriptiveBuilder.setMedian(median); if (isNumeric(descriptiveStats.getVariance())) descriptiveBuilder.setVariance(descriptiveStats.getVariance()); Math.ContinuousSummaryDto.Builder continuousBuilder = Math.ContinuousSummaryDto.newBuilder() .addAllDistributionPercentiles(summary.getDistributionPercentiles()); for (IntervalFrequency.Interval interval : summary.getIntervalFrequencies()) { Math.IntervalFrequencyDto.Builder freqBuilder = Math.IntervalFrequencyDto.newBuilder() .setFreq(interval.getFreq()); if (isNumeric(interval.getLower())) freqBuilder.setLower(interval.getLower()); if (isNumeric(interval.getUpper())) freqBuilder.setUpper(interval.getUpper()); if (isNumeric(interval.getDensity())) freqBuilder.setDensity(interval.getDensity()); if (isNumeric(interval.getDensityPct())) freqBuilder.setDensityPct(interval.getDensityPct()); continuousBuilder.addIntervalFrequency(freqBuilder); } for (ContinuousVariableSummary.Frequency frequency : summary.getFrequencies()) { Math.FrequencyDto.Builder freqBuilder = Math.FrequencyDto.newBuilder() // .setValue(frequency.getValue()) // .setFreq(frequency.getFreq())// .setMissing(frequency.isMissing()); if (isNumeric(frequency.getPct())) freqBuilder.setPct(frequency.getPct()); continuousBuilder.addFrequencies(freqBuilder); } return continuousBuilder.setSummary(descriptiveBuilder); }
From source file:performancestatisticsasset.DistributionSet.java
public void setDistributionSet(String targetGroup, String targetTask, String targetMeasure, RecordList dataSet) {//from w w w . j av a2 s . c o m //Determine the number of trials selected by group and by task int trials = 0; int len = dataSet.records.size(); for (int i = 0; i < len; i++) { if (dataSet.records.get(i).getTrialNumber() > trials) trials = dataSet.records.get(i).getTrialNumber(); } Distribution tempDist; DescriptiveStatistics tempStat; //For each trial of the set do for (int i = 0; i < trials; i++) { tempDist = new Distribution(); tempStat = new DescriptiveStatistics(); //Select data for (int j = 0; j < len; j++) { //If the current record is of the correct trial if ((dataSet.records.get(j).getTrialNumber() == i + 1) && (targetGroup.equals(dataSet.records.get(j).getGroupID())) && (targetTask.equals(dataSet.records.get(j).getTaskID()))) { //Fill distribution switch (targetMeasure) { case "time": tempStat.addValue(dataSet.records.get(j).getTimeToComplete()); break; case "perf": tempStat.addValue(dataSet.records.get(j).getPerformance()); break; } } } //Transfer the computed statistics to tempDist tempDist.max = tempStat.getMax(); tempDist.min = tempStat.getMin(); tempDist.sum = tempStat.getSum(); tempDist.variance = tempStat.getVariance(); tempDist.mean = tempStat.getMean(); tempDist.stdDev = tempStat.getStandardDeviation(); tempDist.skewness = tempStat.getSkewness(); tempDist.kurtosis = tempStat.getKurtosis(); tempDist.n = tempStat.getN(); //Add tempDist to distributionSet distributionSet.add(tempDist); } }