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.

  • Method Summary

    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

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • max

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      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

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

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

      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

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

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

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

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

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

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

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