List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getMax
public double getMax()
From source file:org.wso2.carbon.ml.database.internal.MLDatabaseService.java
/** * Create the JSON string with summary statistics for a column. * * @param type Data-type of the column/*from w w w. j ava 2s .c o m*/ * @param graphFrequencies Bin frequencies of the column * @param missing Number of missing values in the column * @param unique Number of unique values in the column * @param descriptiveStats DescriptiveStats object of the column * @return JSON representation of the summary statistics of the column */ private JSONArray createJson(String type, SortedMap<?, Integer> graphFrequencies, int missing, int unique, DescriptiveStatistics descriptiveStats) throws JSONException { JSONObject json = new JSONObject(); JSONArray freqs = new JSONArray(); Object[] categoryNames = graphFrequencies.keySet().toArray(); // Create an array with intervals/categories and their frequencies. for (int i = 0; i < graphFrequencies.size(); i++) { JSONArray temp = new JSONArray(); temp.put(categoryNames[i].toString()); temp.put(graphFrequencies.get(categoryNames[i])); freqs.put(temp); } // Put the statistics to a json object json.put("unique", unique); json.put("missing", missing); DecimalFormat decimalFormat = new DecimalFormat("#.###"); if (descriptiveStats.getN() != 0) { json.put("mean", decimalFormat.format(descriptiveStats.getMean())); json.put("min", decimalFormat.format(descriptiveStats.getMin())); json.put("max", decimalFormat.format(descriptiveStats.getMax())); json.put("median", decimalFormat.format(descriptiveStats.getPercentile(50))); json.put("std", decimalFormat.format(descriptiveStats.getStandardDeviation())); if (type.equalsIgnoreCase(FeatureType.NUMERICAL)) { json.put("skewness", decimalFormat.format(descriptiveStats.getSkewness())); } } json.put("values", freqs); json.put("bar", true); json.put("key", "Frequency"); JSONArray summaryStatArray = new JSONArray(); summaryStatArray.put(json); return summaryStatArray; }
From source file:performancestatisticsasset.DistributionSet.java
public void setDistributionSet(String targetGroup, String targetTask, String targetMeasure, RecordList dataSet) {/*from w w w . j a v a 2 s . c om*/ //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); } }
From source file:performancestatisticsasset.DistributionSet.java
public void setDistributionSet(String targetTask, String targetMeasure, RecordList dataSet) { //Determine the number of trials selected 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(); }// w ww .j a va 2s. com 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) && (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); } }
From source file:Pooling.collectStatsTime.java
public static void main(String[] args) throws IOException { /* int maxN = 1000; double[] prob = {0.25,0.5,0.75,1.00}; int[] maxPoolSize = {35};//from w w w . ja v a 2 s . c o m int nTests = 50; String folder = "randGraphsSimRes"; for (int t = 0; t < maxPoolSize.length; t++) { FileWriter fw = new FileWriter(folder + File.separator + "statsDesignTime" + maxPoolSize[t] + ".txt"); for (int n = 10; n <= maxN; n+=10) { DescriptiveStatistics stats = new DescriptiveStatistics(); for (int i = 1; i <= nTests; i++) { String resfile = "testResults_" + n + "_" + maxPoolSize[t] + "_" + i + ".txt"; BufferedReader br = new BufferedReader(new FileReader(folder + File.separator + resfile)); System.out.println(resfile); String s = br.readLine(); StringTokenizer st = new StringTokenizer(s," "); st.nextToken(); int k = Integer.parseInt(st.nextToken()); stats.addValue(((double)k)/1000); } fw.write(n + " " + stats.getMean() + " " + (stats.getStandardDeviation()/Math.sqrt(nTests)) + "\n"); } fw.close(); } */ int[] ns = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150 }; int[] maxPoolSizes = { 15, 25, 35 }; int nTests = 10; for (int sz = 0; sz < maxPoolSizes.length; sz++) { FileWriter fw = new FileWriter("statisticsTime_" + maxPoolSizes[sz] + ".txt"); for (int in = 0; in < ns.length; in++) { DescriptiveStatistics stats = new DescriptiveStatistics(); for (int it = 0; it < nTests; it++) { String outdir = "Test_" + maxPoolSizes[sz] + "_" + ns[in] + "_" + it; String repFile = outdir + File.separator + "report.txt"; System.out.println(outdir); BufferedReader br = new BufferedReader(new FileReader(repFile)); String s = ""; for (int i = 0; i < 6; i++) s = br.readLine(); StringTokenizer st = new StringTokenizer(s, ":"); st.nextToken(); double tm = Double.parseDouble(st.nextToken()); stats.addValue(tm); } double maxtime = stats.getMax(); DescriptiveStatistics stats1 = new DescriptiveStatistics(); for (int i = 0; i < nTests; i++) if (stats.getElement(i) != maxtime) stats1.addValue(stats.getElement(i)); fw.write(ns[in] + " " + stats1.getMean() + " " + (stats1.getStandardDeviation() / Math.sqrt((nTests - 1))) + "\n"); } fw.close(); } }
From source file:sandbox.sfwatergit.peerinfluence.io.TXTWriter.java
public static void writeStatistics(TDoubleObjectHashMap<DescriptiveStatistics> statsMap, String xLab, String file) throws IOException { double[] keys = statsMap.keys(); Arrays.sort(keys);/*w w w .j a va2 s . co m*/ BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.write(xLab); writer.write(TAB); writer.write("mean"); writer.write(TAB); writer.write("median"); writer.write(TAB); writer.write("min"); writer.write(TAB); writer.write("max"); writer.write(TAB); writer.write("n"); writer.newLine(); for (double key : keys) { DescriptiveStatistics stats = statsMap.get(key); writer.write(String.valueOf(key)); writer.write(TAB); writer.write(String.valueOf(stats.getMean())); writer.write(TAB); writer.write(String.valueOf(stats.getPercentile(50))); writer.write(TAB); writer.write(String.valueOf(stats.getMin())); writer.write(TAB); writer.write(String.valueOf(stats.getMax())); writer.write(TAB); writer.write(String.valueOf(stats.getN())); writer.newLine(); } writer.close(); }
From source file:tools.descartes.bungee.examples.ShowResponsetimeChart.java
/** * Starting point for the demonstration application. * * @param args ignored./* w ww . j av a 2s .com*/ */ public static void main(final String[] args) { RunResult result = RunResult.read(new File(FileUtility.FILE_LOCATION, "measurement/141.21.72.21_500000_2014.04.01_15.41.14/result.runresult")); JFreeChart chart = ChartGenerator.responseTimeChart(result, 1); ChartGenerator.showChart(chart, "Graph"); DescriptiveStatistics responseTimeStats = result.getResponseTimeStats(); System.out.println("Max: " + responseTimeStats.getMax()); //ChartPDFWriter.writeChartToPDF(chart, 800,300, new File("responseChart.pdf")); }
From source file:tools.descartes.bungee.utils.DiffUtil.java
public static <T> Stats statisticsForDiffs(List<T> objects) { DescriptiveStatistics statistics = createDescriptiveStatistics(objects); Stats stats = new Stats(); // Compute some statistics stats.mean = statistics.getMean();/*from w ww .j a va2s. co m*/ stats.std = statistics.getStandardDeviation(); stats.max = Math.max(statistics.getMax(), -statistics.getMin()); return stats; }
From source file:tools.descartes.bungee.utils.DiffUtil.java
public static <T> StatsPercentile statisticsForDiffs(List<T> objects, double percent) { // Get a DescriptiveStatistics instance DescriptiveStatistics statistics = new DescriptiveStatistics(); // Add the data from the array for (T object : objects) { if (object instanceof Long) { statistics.addValue((Long) object); } else if (object instanceof Double) { statistics.addValue((Double) object); } else if (object instanceof AbstractResponse) { statistics.addValue(((AbstractResponse) object).getResponseTime()); }/* w w w .j a v a2 s. co m*/ } StatsPercentile stats = new StatsPercentile(); // Compute some statistics stats.mean = statistics.getMean(); stats.std = statistics.getStandardDeviation(); stats.max = Math.max(statistics.getMax(), -statistics.getMin()); stats.percent = percent; stats.percentile = statistics.getPercentile(percent); return stats; }
From source file:uk.ac.soton.itinnovation.ecc.service.utils.ExplorerDemoData.java
public EccINTRATSummary getINTRATDistDataDiscrete(UUID attrID, ArrayList<Date> stamps) { EccINTRATSummary result = null;/*from w w w .ja v a 2s . co m*/ // Safety if (attrID != null && stamps != null) { EccAttributeInfo info = qosAttributesByID.get(attrID); EccINTRATSeries srcSeries = qosSeries.get(attrID); if (info != null && srcSeries != null) { // Copy source series data with just those timestamps ArrayList<EccMeasurement> targMeasures = new ArrayList<>(); for (EccMeasurement srcM : srcSeries.getValues()) for (Date targDate : stamps) if (srcM.getTimestamp().equals(targDate)) targMeasures.add(new EccMeasurement(srcM)); // If we've got any data, create a summary if (!targMeasures.isEmpty()) { DescriptiveStatistics ds = new DescriptiveStatistics(); for (EccMeasurement m : targMeasures) ds.addValue(Double.parseDouble(m.getValue())); result = new EccINTRATSummary(info, ds.getMin(), ds.getMean(), ds.getMax()); } } } return result; }
From source file:uk.ac.soton.itinnovation.ecc.service.utils.ExplorerDemoData.java
public EccINTRATSummary getQosSummary(UUID attrID) { EccINTRATSummary result = null;//w w w .j a v a 2s . co m if (attrID != null) { // Find QoS series and calculate summary data EccINTRATSeries series = qosSeries.get(attrID); if (series != null) { DescriptiveStatistics ds = new DescriptiveStatistics(); for (EccMeasurement m : series.getValues()) ds.addValue(Double.parseDouble(m.getValue())); result = new EccINTRATSummary(qosAttributesByID.get(attrID), ds.getMin(), ds.getMean(), ds.getMax()); } } return result; }