module analysis::statistics::Descriptive
Descriptive Statistics.
Usage
import analysis::statistics::Descriptive;
Dependencies
import Exception;
import util::Math;
import List;
Description
Provides the following univariate (single variable) statistics functions:
- centralMoment
- geometricMean
- kurtosis
- kurtosisExcess
- max
- mean
- median
- middle
- min
- moment
- percentile
- skewness
- standardDeviation
- sum
- sumsq
- variance
Examples
rascal>import analysis::statistics::Descriptive;
ok
rascal>D = [67, 88, 55, 92.5, 102, 51];
list[num]: [67,88,55,92.5,102,51]
rascal>mn = min(D);
num: 51
rascal>mx = max(D);
num: 102
rascal>range = mx - mn;
num: 51
rascal>midrange = mn + range/2;
num: 76.5
rascal>sum(D);
num: 455.5
rascal>mean(D);
real: 75.91666667
rascal>geometricMean(D);
real: 73.3734107237
rascal>standardDeviation(D);
real: 21.1622698845
rascal>variance(D);
num: 447.841666666666666666666666666
rascal>percentile(D,25);
num: 55
rascal>percentile(D,50);
num: 67
rascal>percentile(D,75);
num: 92.5
function geometricMean
Geometric mean of data values.
real geometricMean([num hd, *num tl])
Computes the geometric mean of the given data values.
function kurtosis
Kurtosis of data values.
real kurtosis(list[num] values:[_, *_])
Computes the kurtosis of the given data values. Kurtosis is a measure of the "peakedness" of a distribution.
function kurtosisExcess
Kurtosis excess of data values.
real kurtosisExcess(list[num] values)
Computes the kurtosis excess of the given data values. Kurtosis excess is a measure of the "peakedness" of a distribution corrected such that a normal distribution will be 0.
function max
Largest data value.
(&T <: num) max([(&T <: num) h, *(&T <: num) t])
function mean
Arithmetic mean of data values.
real mean(list[num] nums:[_, *_])
Computes the arithmetic mean of the data values.
function median
Median of data values.
default real median(list[num] nums:[_, *_])
Returns the median of the available values. This is the same as the 50th Percentile.
Examples
rascal>import analysis::statistics::Descriptive;
ok
rascal>median([1,2,5,7,8]);
real: 5.
rascal>median([1,2,2,6,7,8]);
real: 4.
function middle
list[&T] middle(list[&T] nums)
function min
Smallest data value.
(&T <: num) min([(&T <: num) h, *(&T <: num) t])
function percentile
Percentile of data values.
&T <: num percentile(list[&T <: num] nums, num p)
Returns the p
th percentile of the data values.
0 < p
<= 100 should hold.
function variance
Variance of data values.
num variance([num hd, *num tl])
Computes the variance of the data values. It measures how far a set of numbers is spread out.
function skewness
Skewness of data values.
real skewness(list[num] values:[_, *_])
Returns the skewness of the available values. Skewness is a measure of the asymmetry of a given distribution.
function standardDeviation
Standard deviation of data values.
real standardDeviation(list[num] values)
Computes the standard deviation of the data values. It shows how much variation exists from the average (mean, or expected value).
function sum
Sum of data values.
(&T <:num) sum([(&T <: num) hd, *(&T <: num) tl])
function sumsq
Sum of the squares of data values.
(&T <:num) sumsq(list[&T <:num] values)
function centralMoment
Calculate the k-th central moment.
real centralMoment(list[num] nums:[_, *_], int order = 1)
function moment
Calculate the k-th moment.
real moment(list[num] nums:[_, *_], int order = 1)