Statistics.Math
Summary
abs(x) | Get the absolute value of a number |
e() | The constant e |
exp(x) | Exponent function |
factorial(n) | Factorial! |
ln(i) | The natural log |
pi() | The constant pi |
pow(num, pow) | Get power from Erlang |
rand() | Get a random number from erlang |
round(x, precision) | Round a decimal to a specific precision |
sqrt(num) | Get square root |
to_int(f) | Get the base integer from a float |
Functions
Exponent function
Raise e to given power
Examples
iex> Statistics.Math.exp(5.6)
270.4264074261525
The natural log
( from Erlang Math module)
Examples
iex> Statistics.Math.ln(20)
2.995732273553991
iex> Statistics.Math.ln(200)
5.298317366548036
The constant pi
(returned from Erlang Math module)
Examples
iex> Statistics.Math.pi
3.141592653589793
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
Round a decimal to a specific precision
Examples
iex> Statistics.Math.round(0.123456, 4)
0.1235
Get square root
return sqrt from Erlang
Examples
iex> Statistics.Math.sqrt(9)
3.0
iex> Statistics.Math.sqrt(99)
9.9498743710662