Class Statistics
java.lang.Object
Jcg.util.Statistics
This class provides basic functions for computing some statistical parameters
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static doubleapprox(double x) private static doubleapprox(double x, int prec) static doublegetAverage(double[] x) Compute the average of the (non negative) values in the array
Remark: negative values are skippedstatic doublegetDeviation(double[] x) Compute the average percent deviation
Remark: negative values are skippedstatic doublegetDeviationOnlyPositive(double[] x) Compute the average percent deviation
Remark: only (strictly) positive values are consideredstatic doublegetEntropyInteger(int[] s, int n) Compute the Shannon entropy (0-entropy) of an integer input sequence.static doublegetMax(double[] x) Compute the maximum of the value in the arraystatic doublegetMin(double[] x) Compute the minimum of the value in the arraystatic double[]getPercentile(double[] data) Given a sorted array as input, it returns the following 5 values:
-) 0 percentile (minimum)
-) 25 percentile
-) 50 percentile (median)
-) 75 percentile
-) 100 percentile (maximum)static StringlatexWhiskerPlot(double[] x, double[][] y) Return the Latex code for drawing the whisker plot of the input data.static StringminMaxToLatexChart(double[] t) Return the Latex code representing a bar chartstatic double[]normalize(double[] x, double norm) Normalized the input data with respect to a given valuestatic Stringpercentile2575ToLatexChart(double[] t) Return the Latex code representing a bar chart
-
Constructor Details
-
Statistics
public Statistics()
-
-
Method Details
-
normalize
public static double[] normalize(double[] x, double norm) Normalized the input data with respect to a given value -
getAverage
public static double getAverage(double[] x) Compute the average of the (non negative) values in the array
Remark: negative values are skipped -
getMax
public static double getMax(double[] x) Compute the maximum of the value in the array -
getMin
public static double getMin(double[] x) Compute the minimum of the value in the array -
getDeviation
public static double getDeviation(double[] x) Compute the average percent deviation
Remark: negative values are skipped -
getDeviationOnlyPositive
public static double getDeviationOnlyPositive(double[] x) Compute the average percent deviation
Remark: only (strictly) positive values are considered -
getPercentile
public static double[] getPercentile(double[] data) Given a sorted array as input, it returns the following 5 values:
-) 0 percentile (minimum)
-) 25 percentile
-) 50 percentile (median)
-) 75 percentile
-) 100 percentile (maximum)- Returns:
- an array of size 5
-
getEntropyInteger
public static double getEntropyInteger(int[] s, int n) Compute the Shannon entropy (0-entropy) of an integer input sequence. Values are assumed to range in [0..n]- Parameters:
s- input sequencen- maximum value in the sequence: all values are in [0..n]
-
minMaxToLatexChart
Return the Latex code representing a bar chart- Parameters:
t- an ordered array containing 5 values [min, perc25, median, perc75, max]- Returns:
- a string representing the bar chart (according to latex Style)
-
percentile2575ToLatexChart
Return the Latex code representing a bar chart- Parameters:
t- an ordered array containing 5 values [min, perc25, median, perc75, max]- Returns:
- a string representing the bar chart (according to latex Style)
-
latexWhiskerPlot
Return the Latex code for drawing the whisker plot of the input data. There are tow kind of boxes:
-) thin box: representing the minimum and maximum values (for the y-range)
-) thick box: representing the percentiles in the range [25%,75%] of the values stored in the array 'y[i]'- Parameters:
x- an array corresponding to the x-coordinates of the 'n' vertical barsy- a double array containing the values to plot. The i-th array 'y[i]' is assumed to be sorted
-
approx
private static double approx(double x) -
approx
private static double approx(double x, int prec)
-