Package stdlib

Class StdStats

java.lang.Object
stdlib.StdStats

public final class StdStats extends Object
Standard statistics. This class provides methods for computing statistics such as min, max, mean, sample standard deviation, and sample variance.

For additional documentation, see Section 2.2 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.

  • Constructor Summary Link icon

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    Test client.
    static double
    max(double[] a)
    Return maximum value in array, -infinity if no such value.
    static double
    max(double[] a, int lo, int hi)
    Return maximum value in subarray a[lo..hi], -infinity if no such value.
    static int
    max(int[] a)
    Return maximum value of array, Integer.MIN_VALUE if no such value
    static double
    mean(double[] a)
    Return average value in array, NaN if no such value.
    static double
    mean(double[] a, int lo, int hi)
    Return average value in subarray a[lo..hi], NaN if no such value.
    static double
    mean(int[] a)
    Return average value in array, NaN if no such value.
    static double
    min(double[] a)
    Return minimum value in array, +infinity if no such value.
    static double
    min(double[] a, int lo, int hi)
    Return minimum value in subarray a[lo..hi], +infinity if no such value.
    static int
    min(int[] a)
    Return minimum value of array, Integer.MAX_VALUE if no such value
    static void
    plotBars(double[] a)
    Plot bars from (0, a[i]) to (i, a[i]) to standard draw.
    static void
    plotLines(double[] a)
    Plot line segments connecting points (i, a[i]) to standard draw.
    static void
    plotPoints(double[] a)
    Plot points (i, a[i]) to standard draw.
    static double
    stddev(double[] a)
    Return sample standard deviation of array, NaN if no such value.
    static double
    stddev(double[] a, int lo, int hi)
    Return sample standard deviation of subarray a[lo..hi], NaN if no such value.
    static double
    stddev(int[] a)
    Return sample standard deviation of array, NaN if no such value.
    static double
    stddevp(double[] a)
    Return population standard deviation of array, NaN if no such value.
    static double
    stddevp(double[] a, int lo, int hi)
    Return population standard deviation of subarray a[lo..hi], NaN if no such value.
    static double
    sum(double[] a)
    Return sum of all values in array.
    static double
    sum(double[] a, int lo, int hi)
    Return sum of all values in subarray a[lo..hi].
    static int
    sum(int[] a)
    Return sum of all values in array.
    static double
    var(double[] a)
    Return sample variance of array, NaN if no such value.
    static double
    var(double[] a, int lo, int hi)
    Return sample variance of subarray a[lo..hi], NaN if no such value.
    static double
    var(int[] a)
    Return sample variance of array, NaN if no such value.
    static double
    varp(double[] a)
    Return population variance of array, NaN if no such value.
    static double
    varp(double[] a, int lo, int hi)
    Return population variance of subarray a[lo..hi], NaN if no such value.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

  • Method Details Link icon

    • max Link icon

      public static double max(double[] a)
      Return maximum value in array, -infinity if no such value.
    • max Link icon

      public static double max(double[] a, int lo, int hi)
      Return maximum value in subarray a[lo..hi], -infinity if no such value.
    • max Link icon

      public static int max(int[] a)
      Return maximum value of array, Integer.MIN_VALUE if no such value
    • min Link icon

      public static double min(double[] a)
      Return minimum value in array, +infinity if no such value.
    • min Link icon

      public static double min(double[] a, int lo, int hi)
      Return minimum value in subarray a[lo..hi], +infinity if no such value.
    • min Link icon

      public static int min(int[] a)
      Return minimum value of array, Integer.MAX_VALUE if no such value
    • mean Link icon

      public static double mean(double[] a)
      Return average value in array, NaN if no such value.
    • mean Link icon

      public static double mean(double[] a, int lo, int hi)
      Return average value in subarray a[lo..hi], NaN if no such value.
    • mean Link icon

      public static double mean(int[] a)
      Return average value in array, NaN if no such value.
    • var Link icon

      public static double var(double[] a)
      Return sample variance of array, NaN if no such value.
    • var Link icon

      public static double var(double[] a, int lo, int hi)
      Return sample variance of subarray a[lo..hi], NaN if no such value.
    • var Link icon

      public static double var(int[] a)
      Return sample variance of array, NaN if no such value.
    • varp Link icon

      public static double varp(double[] a)
      Return population variance of array, NaN if no such value.
    • varp Link icon

      public static double varp(double[] a, int lo, int hi)
      Return population variance of subarray a[lo..hi], NaN if no such value.
    • stddev Link icon

      public static double stddev(double[] a)
      Return sample standard deviation of array, NaN if no such value.
    • stddev Link icon

      public static double stddev(double[] a, int lo, int hi)
      Return sample standard deviation of subarray a[lo..hi], NaN if no such value.
    • stddev Link icon

      public static double stddev(int[] a)
      Return sample standard deviation of array, NaN if no such value.
    • stddevp Link icon

      public static double stddevp(double[] a)
      Return population standard deviation of array, NaN if no such value.
    • stddevp Link icon

      public static double stddevp(double[] a, int lo, int hi)
      Return population standard deviation of subarray a[lo..hi], NaN if no such value.
    • sum Link icon

      public static double sum(double[] a)
      Return sum of all values in array.
    • sum Link icon

      public static double sum(double[] a, int lo, int hi)
      Return sum of all values in subarray a[lo..hi].
    • sum Link icon

      public static int sum(int[] a)
      Return sum of all values in array.
    • plotPoints Link icon

      public static void plotPoints(double[] a)
      Plot points (i, a[i]) to standard draw.
    • plotLines Link icon

      public static void plotLines(double[] a)
      Plot line segments connecting points (i, a[i]) to standard draw.
    • plotBars Link icon

      public static void plotBars(double[] a)
      Plot bars from (0, a[i]) to (i, a[i]) to standard draw.
    • main Link icon

      public static void main(String[] args)
      Test client. Convert command-line arguments to array of doubles and call various methods.