exmath v0.2.5 Exmath
Summary
Functions
See :math.acos/1
See :math.asin/1
See :math.atan/1
Get the average growth between two points in a graph
Calculates the n-th bell number. A bell number is how many ways you can partition n elements
See :math.cos/1
See :math.cosh/1
See :math.exp/1
Factorial will multiply n with n-1 until n <= 1
Hypergeometric distribution without replacement
See :math.log/1
See :math.log2/1
Combinations formula. A formula for the number of possible combinations of r elements from a set of n elements. In combinations order doesn’t matter
Permutations formula. A formula for the number of possible permutations of r elements from a set of n elements
Prints row r of Pascal’s triangle. Calculated using the previously implemented nCr formula. Be aware; Pascal’s triangle starts with 0 both column- and row-wise
See :math.pow/2
Calculates the hypothenus using the pythagoras theorem
See :math.sin/1
See :math.sinh/1
See :math.sqrt/1
Computes the stirling number of the second kind. This is how many ways you can partition n elements into k groups
See :math.tan/1
See :math.tanh/1
Functions
See :math.acos/1
.
See :math.acosh/1
.
See :math.asin/1
.
See :math.asinh/1
.
See :math.atan/1
.
See :math.atan2/2
.
See :math.atanh/1
.
Get the average growth between two points in a graph.
Example
Imagine we have the two points (1, 1) and (10, 10). The mathematical formula for calculating this is delta-y/delta-x.
iex> Exmath.average_growth({1, 1}, {10, 10})
1.0
Calculates the n-th bell number. A bell number is how many ways you can partition n elements.
Example
If you have a set of 10 images, how many different ways can you group them?
iex> Exmath.bell_number(10)
115_975.0
See :math.cos/1
.
See :math.cosh/1
.
See :math.exp/1
.
Factorial will multiply n with n-1 until n <= 1.
Example
iex> Exmath.factorial(4)
24
hypergeometric_distribution(number, number, number, number) :: float
Hypergeometric distribution without replacement
Parameters
- k -> how many wins
- nn -> total pool
- kk -> target total (wins + losses)
- n -> how many to draw
Example
Imagine we have an urn of 50 marbles. 5 green ones and 45 red ones. Blindly we will take 10 marbles from the urn. What is the likelihood that we will draw 4 green and 6 red marbles.
This means we will have k=4, n=10, N=50, K=5.
iex> Float.round Exmath.hypergeometric_distribution(4, 50, 5, 10), 5
0.00396
See :math.log/1
.
See :math.log10/1
.
See :math.log2/1
.
Combinations formula. A formula for the number of possible combinations of r elements from a set of n elements. In combinations order doesn’t matter.
Example
We have 5 balls, in how many ways can we select 3 of them?
iex> Exmath.nCr(5, 3)
10.0
Permutations formula. A formula for the number of possible permutations of r elements from a set of n elements.
Example
How many ways can 4 students from a group of 15 be lined up for a photograph?
iex> Exmath.nPr(15, 4)
32760.0
Prints row r of Pascal’s triangle. Calculated using the previously implemented nCr formula. Be aware; Pascal’s triangle starts with 0 both column- and row-wise.
Example
What is the 4th row of pascals triangle.
iex> Exmath.pascals_triangle_row(3)
[1.0, 3.0, 3.0, 1.0]
See :math.pow/2
.
Calculates the hypothenus using the pythagoras theorem
Example
iex> Exmath.pythagoras(4, 3) 5.0
See :math.sin/1
.
See :math.sinh/1
.
See :math.sqrt/1
.
Computes the stirling number of the second kind. This is how many ways you can partition n elements into k groups.
Example
Let’s say you have 10 images, how many ways can you partition those images into 3 groups?
iex> Exmath.stirlings2(10, 3)
9330.0
See :math.tan/1
.
See :math.tanh/1
.