Class Statistics

java.lang.Object
Jcg.util.Statistics

public class Statistics extends Object
This class provides basic functions for computing some statistical parameters
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static double
    approx(double x)
     
    private static double
    approx(double x, int prec)
     
    static double
    getAverage(double[] x)
    Compute the average of the (non negative) values in the array
    Remark: negative values are skipped
    static double
    getDeviation(double[] x)
    Compute the average percent deviation
    Remark: negative values are skipped
    static double
    Compute the average percent deviation
    Remark: only (strictly) positive values are considered
    static double
    getEntropyInteger(int[] s, int n)
    Compute the Shannon entropy (0-entropy) of an integer input sequence.
    static double
    getMax(double[] x)
    Compute the maximum of the value in the array
    static double
    getMin(double[] x)
    Compute the minimum of the value in the array
    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)
    static String
    latexWhiskerPlot(double[] x, double[][] y)
    Return the Latex code for drawing the whisker plot of the input data.
    static String
    minMaxToLatexChart(double[] t)
    Return the Latex code representing a bar chart
    static double[]
    normalize(double[] x, double norm)
    Normalized the input data with respect to a given value
    static String
    Return the Latex code representing a bar chart

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 sequence
      n - maximum value in the sequence: all values are in [0..n]
    • minMaxToLatexChart

      public static String minMaxToLatexChart(double[] t)
      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

      public static String percentile2575ToLatexChart(double[] t)
      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

      public static String latexWhiskerPlot(double[] x, double[][] y)
      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 bars
      y - 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)