Difference between revisions of "Functions for descriptive statistics"
From Free Pascal wiki
Jump to navigationJump to searchJwdietrich (talk | contribs) |
Jwdietrich (talk | contribs) |
||
Line 5: | Line 5: | ||
The unit [[doc:rtl/math/index.html|math]] of the [[RTL]] provides a plethora of routines for descriptive statistics. | The unit [[doc:rtl/math/index.html|math]] of the [[RTL]] provides a plethora of routines for descriptive statistics. | ||
− | * [[doc:rtl/math/mean.html|mean]]: Returns the mean value of an array. | + | * <code>[[doc:rtl/math/mean.html|mean]]</code>: Returns the mean value of an array. |
− | * [[doc:rtl/math/stddev.html| stddev]]: Returns the (sample) standard deviation of an array. | + | * <code>[[doc:rtl/math/stddev.html| stddev]]</code>: Returns the (sample) standard deviation of an array. |
− | * [[doc:rtl/math/popnstddev.html| popnstddev]]: Returns the (population) standard deviation of an array. | + | * <code>[[doc:rtl/math/popnstddev.html| popnstddev]]</code>: Returns the (population) standard deviation of an array. |
− | * [[doc:rtl/math/meanandstddev.html| meanandstddev]]: Returns mean and standard deviation of an array. | + | * <code>[[doc:rtl/math/meanandstddev.html| meanandstddev]]</code>: Returns mean and standard deviation of an array. |
− | * [[doc:rtl/math/momentskewkurtosis.html| momentskewkurtosis]]: Returns the first four moments of an array. | + | * <code>[[doc:rtl/math/momentskewkurtosis.html| momentskewkurtosis]]</code>: Returns the first four moments of an array. |
− | * [[doc:rtl/math/variance.html| variance]]: Returns the (sample) variance of an array. | + | * <code>[[doc:rtl/math/variance.html| variance]]</code>: Returns the (sample) variance of an array. |
− | * [[doc:rtl/math/popnvariance.html| popnvariance]]: Returns the (population) variance of an array. | + | * <code>[[doc:rtl/math/popnvariance.html| popnvariance]]</code>: Returns the (population) variance of an array. |
− | * [[doc:rtl/math/totalvariance.html| totalvariance]]: Returns the total variance of an array. | + | * <code>[[doc:rtl/math/totalvariance.html| totalvariance]]</code>: Returns the total variance of an array. |
− | * [[doc:rtl/math/sumofsquares.html| sumofsquares]]: Returns the sum of squares of an array. | + | * <code>[[doc:rtl/math/sumofsquares.html| sumofsquares]]</code>: Returns the sum of squares of an array. |
− | * [[doc:rtl/math/sum.html| sum]]: Returns the sum of values of an array. | + | * <code>[[doc:rtl/math/sum.html| sum]]</code>: Returns the sum of values of an array. |
− | * [[doc:rtl/math/sumsandsquares.html| sumsandsquares]]: Returns sum and sum of squares of the values in an array. | + | * <code>[[doc:rtl/math/sumsandsquares.html| sumsandsquares]]</code>: Returns sum and sum of squares of the values in an array. |
+ | |||
+ | These functions expect an array of predefined length (e.g. <code>array[1..100] of float</code>) or a 0-based open array (e.g. array of extended) with subsequent call of the <code>[[doc:rtl/system/setlength.html| SetLength]]</code> procedure. | ||
== Standard functions defined in other units == | == Standard functions defined in other units == |
Revision as of 23:48, 11 January 2015
Descriptive statistics aim at characterising empirical data by summative parameters (and also by tables and plots}.
Standard functions defined in math unit
The unit math of the RTL provides a plethora of routines for descriptive statistics.
mean
: Returns the mean value of an array.stddev
: Returns the (sample) standard deviation of an array.popnstddev
: Returns the (population) standard deviation of an array.meanandstddev
: Returns mean and standard deviation of an array.momentskewkurtosis
: Returns the first four moments of an array.variance
: Returns the (sample) variance of an array.popnvariance
: Returns the (population) variance of an array.totalvariance
: Returns the total variance of an array.sumofsquares
: Returns the sum of squares of an array.sum
: Returns the sum of values of an array.sumsandsquares
: Returns sum and sum of squares of the values in an array.
These functions expect an array of predefined length (e.g. array[1..100] of float
) or a 0-based open array (e.g. array of extended) with subsequent call of the SetLength
procedure.
Standard functions defined in other units
- length: Delivers the length (n) of an array.
Custom functions
Standard error of the mean
The standard error of the mean (SEM) is a measure that estimates how precisely the true mean of the population can be known.
Calculation of SEM is simple:
function sem(const data: array of Extended): real;
begin
sem := stddev(data) / sqrt(length(data));
end;