Package stdlib
Class StdStats
java.lang.Object
stdlib.StdStats
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 TypeMethodDescriptionstatic void
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 valuestatic 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 valuestatic 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.
-
Method Details
-
max
Return maximum value in array, -infinity if no such value. -
max
Return maximum value in subarray a[lo..hi], -infinity if no such value. -
max
Return maximum value of array, Integer.MIN_VALUE if no such value -
min
Return minimum value in array, +infinity if no such value. -
min
Return minimum value in subarray a[lo..hi], +infinity if no such value. -
min
Return minimum value of array, Integer.MAX_VALUE if no such value -
mean
Return average value in array, NaN if no such value. -
mean
Return average value in subarray a[lo..hi], NaN if no such value. -
mean
Return average value in array, NaN if no such value. -
var
Return sample variance of array, NaN if no such value. -
var
Return sample variance of subarray a[lo..hi], NaN if no such value. -
var
Return sample variance of array, NaN if no such value. -
varp
Return population variance of array, NaN if no such value. -
varp
Return population variance of subarray a[lo..hi], NaN if no such value. -
stddev
Return sample standard deviation of array, NaN if no such value. -
stddev
Return sample standard deviation of subarray a[lo..hi], NaN if no such value. -
stddev
Return sample standard deviation of array, NaN if no such value. -
stddevp
Return population standard deviation of array, NaN if no such value. -
stddevp
Return population standard deviation of subarray a[lo..hi], NaN if no such value. -
sum
Return sum of all values in array. -
sum
Return sum of all values in subarray a[lo..hi]. -
sum
Return sum of all values in array. -
plotPoints
Plot points (i, a[i]) to standard draw. -
plotLines
Plot line segments connecting points (i, a[i]) to standard draw. -
plotBars
Plot bars from (0, a[i]) to (i, a[i]) to standard draw. -
main
Test client. Convert command-line arguments to array of doubles and call various methods.
-