Skip to content

Latest commit

 

History

History
174 lines (118 loc) · 3.93 KB

stat.md

File metadata and controls

174 lines (118 loc) · 3.93 KB

stat

Statistical calculations

Index

Operation Description
average, avg Average
binomial Binomial coefficient
factorial, fact Factorial
prod
standard.dev.pop, stdev.p Population standard deviation
standard.dev.samp, stdev.s Population standard deviation
sum Summation
variance.pop, var.p Population variance
variance.samp, var.s Sample variance

Operations

average

The average, or aritmetic mean, of the values on the stack. A division undefined error is raised if the stack is empty.

Alias: avg

Macro definition:

def average n push sum pop div

Example:

Input Stack
0 100 25 75 average 50

binomial

Binomial coefficient where k elements are chosen from a set of n.

Stack effects:

( n:Int/s64 k:Int/s64 -- Int )

Example:

Input Stack
4 2 binomial 6

factorial

The product of all positive integers less than or equal to n. If n is negative, an invalid argument error is raised.

Alias: fact

Stack effects:

( x:Int/u -- Int )

Example:

Input Stack
c 3 fact 6
c 10 fact 3628800

prod

The product of all items on the stack. If there are no items on the stack, a one is placed on the stack.

Macro definition:

def prod 1 /mul fold

standard.dev.pop

Standard deviation of the stack where it contains the entire population

Alias: stdev.p

Macro definition:

def standard.dev.pop var.p sqrt

Example:

Input Stack
2 4 4 4 5 5 7 9 2 | 4 | 4 | 4 | 5 | 5 | 7 | 9
stdev.p 2

standard.dev.samp

Standard deviation of the stack where it contains the entire population

Alias: stdev.s

Macro definition:

def standard.dev.samp var.s sqrt

Example:

Input Stack
2 4 4 4 5 5 7 9 2 | 4 | 4 | 4 | 5 | 5 | 7 | 9
stdev.s 2 round 2.14

sum

The sum of all items on the stack. If there are no items on the stack, a zero is placed on the stack.

Macro definition:

def sum 0 /add fold

Example:

Input Stack
1 2 3 4 5 1 | 2 | 3 | 4 | 5
sum 15

variance.pop

Variance of the stack where it contains the entire population.

Alias: var.p

Stack effects:

( Real* -- Real )

Example:

Input Stack
2 4 4 4 5 5 7 9 2 | 4 | 4 | 4 | 5 | 5 | 7 | 9
var.p 4

variance.samp

Variance of the stack where it contains a sample of the population.

Alias: var.s

Stack effects:

( Real* -- Real )

Example:

Input Stack
2 4 4 4 5 5 7 9 2 | 4 | 4 | 4 | 5 | 5 | 7 | 9
var.s 2 round 4.57