PHP Класс MathPHP\Probability\Combinatorics

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
catalanNumber ( integer $n ) : integer Catalan number
centralBinomialCoefficient ( integer $n ) : integer Central Binomial Coefficient
combinations ( integer $n, integer $k, boolean $repetition = false ) : integer Combinations - Binomial Coefficient Number of ways of picking k unordered outcomes from n possibilities n choose k: number of possible combinations of n objects taken k at a time.
doubleFactorial ( integer $n ) : integer Double facatorial (iterative) Also known as semifactorial
factorial ( integer $n ) : integer Factorial (iterative) Represents the number of ways to arrange n things (permutations) n! = n(n - 1)(n - 2) ・・・ (n - (n - 1))
fallingFactorial ( number $x, integer $n ) : number Falling Factorial Also known as descending factorial, falling sequential product, lower factorial.
lahNumber ( integer $n, integer $k ) : number Lah number Coefficients expressing rising factorials in terms of falling factorials.
multinomial ( array $groups ) : integer Multinomial coefficient (Multinomial Theorem) Finds the number of divisions of n items into r distinct nonoverlapping subgroups of sizes k₁, k₂, etc.
permutations ( integer $n, integer $k = null ) : integer Permutations (ordered arrangements)
risingFactorial ( number $x, integer $n ) : number Rising Factorial Also known as Pochhammer function, Pochhammer polynomial, ascending factorial, rising sequential product, upper factorial.
subfactorial ( integer $n ) : integer Subfactorial - Derangement number (iterative) The number of permutations of n objects in which no object appears in its natural place.

Описание методов

catalanNumber() публичный статический Метод

1 (2n) Cn = ----- ( ) for n ≥ 0 n + 1 (n ) https://en.wikipedia.org/wiki/Catalan_number
public static catalanNumber ( integer $n ) : integer
$n integer
Результат integer number

centralBinomialCoefficient() публичный статический Метод

(2n) (2n)! ( ) = ----- for n ≥ 0 (n ) (n!)² https://en.wikipedia.org/wiki/Central_binomial_coefficient
public static centralBinomialCoefficient ( integer $n ) : integer
$n integer
Результат integer number

combinations() публичный статический Метод

Without repetition: (n) n! nCk = ( ) = ---------- (k) (n - k)!k! With repetition: (n) (n + k - 1)! nC'k = ( ) = ------------ (k) (n - 1)!k! http://mathworld.wolfram.com/BinomialCoefficient.html
public static combinations ( integer $n, integer $k, boolean $repetition = false ) : integer
$n integer
$k integer
$repetition boolean Whether to do n choose k with or without repetitions
Результат integer number of possible combinations of n objects taken k at a time

doubleFactorial() публичный статический Метод

The product of all the integers from 1 up to some non-negative integer n that have the same parity as n. Denoted by n!! n‼︎ = n(n - 2)(n - 4) ・・・ For even n: n/2 n‼︎ = ∏ (2k) = n(n - 2) ・・・ 2 k=1 For odd n: (n+1)/2 n‼︎ = ∏ (2k - 1) = n(n - 2) ・・・ 1 k=1 0‼︎ = 1
public static doubleFactorial ( integer $n ) : integer
$n integer
Результат integer

factorial() публичный статический Метод

Factorial (iterative) Represents the number of ways to arrange n things (permutations) n! = n(n - 1)(n - 2) ・・・ (n - (n - 1))
public static factorial ( integer $n ) : integer
$n integer
Результат integer number of permutations of n

fallingFactorial() публичный статический Метод

https://en.wikipedia.org/wiki/Falling_and_rising_factorials x₍ᵢ₎ = x * (x - 1) * (x - 2) ... (x - i + 1)
public static fallingFactorial ( number $x, integer $n ) : number
$x number
$n integer
Результат number

lahNumber() публичный статический Метод

https://en.wikipedia.org/wiki/Lah_number n - 1 \ n! L(n,k) = | | -- \ k - 1 / k!
public static lahNumber ( integer $n, integer $k ) : number
$n integer
$k integer
Результат number

multinomial() публичный статический Метод

n! (n₁ + n₂ + ⋯ + nk)! ---------- = ------------------- k₁!k₂!⋯km! k₁!k₂!⋯km! http://mathworld.wolfram.com/MultinomialCoefficient.html https://en.wikipedia.org/wiki/Multinomial_theorem
public static multinomial ( array $groups ) : integer
$groups array Sizes of each subgroup
Результат integer Number of divisions of n items into r distinct nonoverlapping subgroups

permutations() публичный статический Метод

nPn - number of permutations of n things, taken n at a time. P(n) = nPn = (N)n = n(n - 1)(n - 2) ・・・ (n - (n - 1)) = n! nPk: number of permutations of n things, taking only k of them. n! P(n,k) = nPk = -------- (n - k)!
public static permutations ( integer $n, integer $k = null ) : integer
$n integer
$k integer (Optional) for nPk permutations
Результат integer number of permutations of n

risingFactorial() публичный статический Метод

https://en.wikipedia.org/wiki/Falling_and_rising_factorials x⁽ⁿ⁾ = x * (x + 1) * (x + 2) ... (x + n - 1)
public static risingFactorial ( number $x, integer $n ) : number
$x number
$n integer
Результат number

subfactorial() публичный статический Метод

n (-1)ⁱ !n = n! ∑ ----- ᵢ₌₀ i! https://en.wikipedia.org/wiki/Derangement http://mathworld.wolfram.com/Subfactorial.html
public static subfactorial ( integer $n ) : integer
$n integer
Результат integer number of permutations of n