List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getKurtosis
public double getKurtosis()
From source file:com.sop4j.SimpleStatistics.java
public static void main(String[] args) { final MersenneTwister rng = new MersenneTwister(); // used for RNG... READ THE DOCS!!! final int[] values = new int[NUM_VALUES]; final DescriptiveStatistics descriptiveStats = new DescriptiveStatistics(); // stores values final SummaryStatistics summaryStats = new SummaryStatistics(); // doesn't store values final Frequency frequency = new Frequency(); // add numbers into our stats for (int i = 0; i < NUM_VALUES; ++i) { values[i] = rng.nextInt(MAX_VALUE); descriptiveStats.addValue(values[i]); summaryStats.addValue(values[i]); frequency.addValue(values[i]);//w w w. j a v a 2s.c o m } // print out some standard stats System.out.println("MIN: " + summaryStats.getMin()); System.out.println("AVG: " + String.format("%.3f", summaryStats.getMean())); System.out.println("MAX: " + summaryStats.getMax()); // get some more complex stats only offered by DescriptiveStatistics System.out.println("90%: " + descriptiveStats.getPercentile(90)); System.out.println("MEDIAN: " + descriptiveStats.getPercentile(50)); System.out.println("SKEWNESS: " + String.format("%.4f", descriptiveStats.getSkewness())); System.out.println("KURTOSIS: " + String.format("%.4f", descriptiveStats.getKurtosis())); // quick and dirty stats (need a little help from Guava to convert from int[] to double[]) System.out.println("MIN: " + StatUtils.min(Doubles.toArray(Ints.asList(values)))); System.out.println("AVG: " + String.format("%.4f", StatUtils.mean(Doubles.toArray(Ints.asList(values))))); System.out.println("MAX: " + StatUtils.max(Doubles.toArray(Ints.asList(values)))); // some stats based upon frequencies System.out.println("NUM OF 7s: " + frequency.getCount(7)); System.out.println("CUMULATIVE FREQUENCY OF 7: " + frequency.getCumFreq(7)); System.out.println("PERCENTAGE OF 7s: " + frequency.getPct(7)); }
From source file:com.github.aptd.simulation.core.statistic.local.CStatistic.java
/** * write data/*from w ww . j ava 2s . c om*/ * * @param p_writer writer instance * @param p_name section name * @param p_statistic statistic value */ private static void apply(final IWriter p_writer, final String p_name, final DescriptiveStatistics p_statistic) { p_writer.section(1, p_name); p_writer.value("geometricmean", p_statistic.getGeometricMean()); p_writer.value("kurtosis", p_statistic.getKurtosis()); p_writer.value("max", p_statistic.getMax()); p_writer.value("min", p_statistic.getMin()); p_writer.value("mean", p_statistic.getMean()); p_writer.value("count", p_statistic.getN()); p_writer.value("25-percentile", p_statistic.getPercentile(0.25)); p_writer.value("75-percentile", p_statistic.getPercentile(0.75)); p_writer.value("populationvariance", p_statistic.getPopulationVariance()); p_writer.value("quadraticmean", p_statistic.getQuadraticMean()); p_writer.value("standdeviation", p_statistic.getStandardDeviation()); p_writer.value("skewness", p_statistic.getSkewness()); p_writer.value("sum", p_statistic.getSum()); p_writer.value("sumsequared", p_statistic.getSumsq()); p_writer.value("variance", p_statistic.getVariance()); }
From source file:com.intuit.tank.service.impl.v1.report.SummaryReportRunner.java
/** * @param key/*from ww w.j a v a 2 s . c o m*/ * @param value * @return */ private static SummaryData getSummaryData(int jobId, String key, DescriptiveStatistics stats) { SummaryData ret = SummaryDataBuilder.summaryData().withJobId(jobId) .withKurtosis(!Double.isNaN(stats.getKurtosis()) ? stats.getKurtosis() : 0).withMax(stats.getMax()) .withMean(stats.getMean()).withMin(stats.getMin()).withPageId(key) .withPercentile10(stats.getPercentile(10)).withPercentile20(stats.getPercentile(20)) .withPercentile30(stats.getPercentile(30)).withPercentile40(stats.getPercentile(40)) .withPercentile50(stats.getPercentile(50)).withPercentile60(stats.getPercentile(60)) .withPercentile70(stats.getPercentile(70)).withPercentile80(stats.getPercentile(80)) .withPercentile90(stats.getPercentile(90)).withPercentile95(stats.getPercentile(95)) .withPercentile99(stats.getPercentile(99)).withSampleSize((int) stats.getN()) .withSkewness(!Double.isNaN(stats.getSkewness()) ? stats.getSkewness() : 0) .withSttDev(!Double.isNaN(stats.getStandardDeviation()) ? stats.getStandardDeviation() : 0) .withVarience(!Double.isNaN(stats.getVariance()) ? stats.getVariance() : 0).build(); return ret; }
From source file:com.intuit.tank.vm.common.util.ReportUtil.java
public static final String[] getSummaryData(String key, DescriptiveStatistics stats) { String[] ret = new String[ReportUtil.SUMMARY_HEADERS.length + PERCENTILES.length]; int i = 0;// ww w . ja v a2 s. co m ret[i++] = key;// Page ID ret[i++] = INT_NF.format(stats.getN());// Sample Size ret[i++] = DOUBLE_NF.format(stats.getMean());// Mean ret[i++] = INT_NF.format(stats.getPercentile(50));// Meadian ret[i++] = INT_NF.format(stats.getMin());// Min ret[i++] = INT_NF.format(stats.getMax());// Max ret[i++] = DOUBLE_NF.format(stats.getStandardDeviation());// Std Dev ret[i++] = DOUBLE_NF.format(stats.getKurtosis());// Kurtosis ret[i++] = DOUBLE_NF.format(stats.getSkewness());// Skewness ret[i++] = DOUBLE_NF.format(stats.getVariance());// Varience for (int n = 0; n < PERCENTILES.length; n++) { ret[i++] = INT_NF.format(stats.getPercentile((Integer) PERCENTILES[n][1]));// Percentiles } return ret; }
From source file:ijfx.core.stats.DefaultImageStatisticsService.java
@Override public Map<String, Double> descriptiveStatisticsToMap(DescriptiveStatistics descriptiveStats) { Map<String, Double> statistics = summaryStatisticsToMap(descriptiveStats); statistics.put(LBL_MEDIAN, descriptiveStats.getPercentile(50)); statistics.put(LBL_KURTOSIS, descriptiveStats.getKurtosis()); statistics.put(LBL_SKEWNESS, descriptiveStats.getSkewness()); return statistics; }
From source file:info.financialecology.finance.utilities.datastruct.DoubleTimeSeries.java
public double unbiasedExcessKurtosis() { DescriptiveStatistics stats = new DescriptiveStatistics(); for (int i = 0; i < this.values.size(); i++) stats.addValue(this.values.get(i)); return stats.getKurtosis(); }
From source file:info.financialecology.finance.utilities.datastruct.DoubleTimeSeries.java
public double unbiasedExcessKurtosisOverInterval(int start, int length) { DescriptiveStatistics stats = new DescriptiveStatistics(); for (int i = start; i < start + length; i++) stats.addValue(this.values.get(i)); return stats.getKurtosis(); }
From source file:com.intuit.tank.persistence.databases.BucketDataItemTest.java
/** * Run the DescriptiveStatistics getStats() method test. * //from w w w .j ava 2s . c o m * @throws Exception * * @generatedBy CodePro at 9/10/14 10:32 AM */ @Test public void testGetStats_1() throws Exception { BucketDataItem fixture = new BucketDataItem(1, new Date(), new DescriptiveStatistics()); DescriptiveStatistics result = fixture.getStats(); assertNotNull(result); assertEquals( "DescriptiveStatistics:\nn: 0\nmin: NaN\nmax: NaN\nmean: NaN\nstd dev: NaN\nmedian: NaN\nskewness: NaN\nkurtosis: NaN\n", result.toString()); assertEquals(Double.NaN, result.getMax(), 1.0); assertEquals(Double.NaN, result.getVariance(), 1.0); assertEquals(Double.NaN, result.getMean(), 1.0); assertEquals(-1, result.getWindowSize()); assertEquals(0.0, result.getSumsq(), 1.0); assertEquals(Double.NaN, result.getKurtosis(), 1.0); assertEquals(0.0, result.getSum(), 1.0); assertEquals(Double.NaN, result.getSkewness(), 1.0); assertEquals(Double.NaN, result.getPopulationVariance(), 1.0); assertEquals(Double.NaN, result.getStandardDeviation(), 1.0); assertEquals(Double.NaN, result.getGeometricMean(), 1.0); assertEquals(0L, result.getN()); assertEquals(Double.NaN, result.getMin(), 1.0); }
From source file:iac_soap.statsq.NormVerdService.java
@Override public NormVerdResponse calculateNormVerd(List<Double> data) throws MyFault { //Service Requirements if (data.isEmpty()) { throw new MyFault("No data is provided"); } else if (data.size() < 2) { throw new MyFault("A minimum of two data elements is required."); }/*from w ww .j a v a 2 s . c o m*/ //Declaring Apache Commons DescriptiveStatistics DescriptiveStatistics stats = new DescriptiveStatistics(); //Filling DescriptiveStatistics class with the provided dataset for (int i = 0; i < data.size(); i++) { stats.addValue(data.get(i)); } //Let the DescriptiveStatistics class calculate the mean and standard deviation double mean = stats.getMean(); double std = stats.getStandardDeviation(); //Implementing the KolmogorovSmirnov test & calculating the kurtosis and skewness NormalDistribution x = new NormalDistribution(mean, std); double p_value = TestUtils.kolmogorovSmirnovTest(x, stats.getValues(), false); double kurtosis = stats.getKurtosis(); double skewness = stats.getSkewness(); boolean result = false; //Check if the dataset is a normal distribution: //KolmogorovSmirnov p_value should be >= 0.05 //Both kurtosis and skewness should be between -2.0 and 2.0 if (kurtosis < 2.0 && kurtosis > -2.0 && skewness < 2.0 && skewness > -2.0 && p_value >= 0.05) { result = true; } //Response message: NormVerdResponse nvr = new NormVerdResponse(result, p_value, kurtosis, skewness); return nvr; }
From source file:com.github.jessemull.microflexdouble.stat.KurtosisTest.java
/** * Tests the plate statistics method.//from w w w . j a v a 2 s . c o m */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, Double> resultMap = new TreeMap<Well, Double>(); Map<Well, Double> returnedMap = kurtosis.plate(plate); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (double bd : well) { input[index++] = bd; ; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getKurtosis(); resultMap.put(well, result); } for (Well well : plate) { double result = Precision.round(resultMap.get(well), precision); double returned = Precision.round(returnedMap.get(well), precision); assertTrue(result == returned); } } }