statistics v0.4.0 Statistics.Math

Summary

Functions

Get the absolute value of a number

Ceiling function

The number of k combinations of n

e()

The constant e

Exponent function

Factorial!

Floor function

The natural log

The number of k permuations of n

The constant pi

Get power from Erlang

Get a random number from erlang

Round a decimal to a specific precision

Get square root

Get the base integer from a float

Functions

abs(x)

Specs

abs(number) :: number

Get the absolute value of a number

Examples

iex> Statistics.Math.abs(-4)
4
ceil(x)

Specs

ceil(number) :: number

Ceiling function

Examples

iex> Statistics.Math.ceil(3.999)
4.0
combination(n, k)

Specs

combination(non_neg_integer, non_neg_integer) :: non_neg_integer

The number of k combinations of n

Both arguments must be integers

Examples

iex> Statistics.Math.combination(10, 3)
120
e()

Specs

e :: number

The constant e

Examples

iex> Statistics.Math.e
2.718281828459045
exp(x)

Specs

exp(number) :: number

Exponent function

Raise e to given power

Examples

iex> Statistics.Math.exp(5.6)
270.42640742615254
factorial(n)

Specs

factorial(non_neg_integer) :: non_neg_integer

Factorial!

floor(x)

Specs

floor(number) :: number

Floor function

Examples

iex> Statistics.Math.floor(3.999)
3.0
ln(i)

Specs

ln(number) :: number

The natural log

( from Erlang Math module)

Examples

iex> Statistics.Math.ln(20)
2.995732273553991
iex> Statistics.Math.ln(200)
5.298317366548036
permutation(n, k)

Specs

permutation(non_neg_integer, non_neg_integer) :: non_neg_integer

The number of k permuations of n

Examples

iex> Statistics.Math.permutation(10, 3)
720
pi()

Specs

pi :: number

The constant pi

(returned from Erlang Math module)

Examples

iex> Statistics.Math.pi
3.141592653589793
pow(num, pow)

Specs

pow(number, number) :: number

Get power from Erlang

This is needed because Elixir doesn’t currently have the ** operator

Examples

iex> Statistics.Math.pow(2,3)
8.0
iex> Statistics.Math.pow(9,9)
387420489.0
iex> Statistics.Math.pow(2,0)
1
iex> Statistics.Math.pow(-2, 1.5)
-2.8284271247461903
iex> Statistics.Math.pow(0, 5)
0
rand()

Specs

rand :: number

Get a random number from erlang

round(x, precision)

Specs

round(number, number) :: number

Round a decimal to a specific precision

Examples

iex> Statistics.Math.round(0.123456, 4)
0.1235
sqrt(num)

Specs

sqrt(number) :: number

Get square root

return sqrt from Erlang

Examples

iex> Statistics.Math.sqrt(9)
3.0
iex> Statistics.Math.sqrt(99)
9.9498743710662
to_int(f)

Specs

to_int(number) :: integer

Get the base integer from a float

Examples

iex> Statistics.Math.to_int(66.6666)
66