sample-var ( seq -- x ) (original) (raw)

Vocabulary
math.statistics

Inputs

seq a sequence

Outputs

x a non-negative real number

Word description
Computes the variance of seq. It's a measurement of the spread of values in a sequence.

Notes
If the number of elements in seq is 1 or less, it outputs 0.

Examples

USING: math.statistics prettyprint ; { 1 } sample-var .
0

USING: math.statistics prettyprint ; { 1 2 3 } sample-var .
1

USING: math.statistics prettyprint ; { 1 2 3 4 } sample-var .
1+2/3

See also
var-ddof, population-var

Definition

IN: math.statistics

: sample-var ( seq -- x ) 1 var-ddof ; inline