Thread overview
mir.combinatorics: reviewers and ideas are wanted
Mar 28, 2016
9il
Mar 28, 2016
jmh530
Mar 28, 2016
Timon Gehr
Mar 28, 2016
jmh530
Mar 29, 2016
Seb
March 28, 2016
Hello All,

Sebastian Wilzbach (aka @greenify) starts mir.combinatorics.

Numeric functions:
- `binomial`

Ranges:
- `permutations` RoR
- `cartesianPower` RoR
- `combinations` RoR
- `combinationsRepeat` RoR

RoR - Range of Ranges

PR: https://github.com/DlangScience/mir/pull/29


Best regards,
Ilya

March 28, 2016
On Monday, 28 March 2016 at 07:24:12 UTC, 9il wrote:
>
> Sebastian Wilzbach (aka @greenify) starts mir.combinatorics.
>

Cool, when I have time I will take a look.
March 28, 2016
On 28.03.2016 09:24, 9il wrote:
> Hello All,
>
> Sebastian Wilzbach (aka @greenify) starts mir.combinatorics.
>
> Numeric functions:
> - `binomial`
>
> Ranges:
> - `permutations` RoR
> - `cartesianPower` RoR
> - `combinations` RoR
> - `combinationsRepeat` RoR
>
> RoR - Range of Ranges
>
> PR: https://github.com/DlangScience/mir/pull/29
>
>
> Best regards,
> Ilya
>

Regarding ideas:
For each range, there should probably be a numeric function computing the length of that range. (e.g. here, binomial corresponds to combinations, there should be factorial corresponding to permutations etc.)

This table might provide some inspiration:
https://en.wikipedia.org/wiki/Twelvefold_way#Formulas

I'd suggest completing the set of functions and ranges such that they cover all cases in this table.
They can then be generalized. (E.g. instead of choosing a subset of a given size, one might want to choose multiple disjoint subsets of given sizes etc.)

Also (both numeric functions and ranges, often more than one range per numeric function):

- https://en.wikipedia.org/wiki/Multinomial_theorem
- https://en.wikipedia.org/wiki/Stirling_numbers_of_the_first_kind
- https://en.wikipedia.org/wiki/Derangement
- https://en.wikipedia.org/wiki/Cyclic_permutation, in particular transpositions
- https://en.wikipedia.org/wiki/Catalan_number

- https://en.wikipedia.org/wiki/Fuss%E2%80%93Catalan_number
- https://en.wikipedia.org/wiki/Narayana_number
- https://en.wikipedia.org/wiki/Delannoy_number
- https://en.wikipedia.org/wiki/Motzkin_number
- https://en.wikipedia.org/wiki/Schr%C3%B6der_number
- https://en.wikipedia.org/wiki/Schr%C3%B6der%E2%80%93Hipparchus_number
- ...
March 28, 2016
On Monday, 28 March 2016 at 15:30:56 UTC, Timon Gehr wrote:
>
> Regarding ideas:
> For each range, there should probably be a numeric function computing the length of that range. (e.g. here, binomial corresponds to combinations, there should be factorial corresponding to permutations etc.)
>

I agree. I had been looking at the Discrete Math toolbox for Matlab to compare functionality and factorial seemed worth adding (as an aside, I saw an earlier thread about adding factorial to std.math and people were like nobody uses factorial and I wanted to punch my computer screen). Matlab's toolbox also has gcd, lcm, and some prime number functions.

I'm not entirely sold on the name of the binomial function. I'm concerned if it will be confusing if working with other dlangscience projects. Looking at dstats there are a bunch of functions with binomial in the name (rBinomial, binomialCDF, etc.). SciPy/SAS uses comb. Matlab uses nchoosek. R uses combn. I'm not a fan of combn.

Other potential overlapping functionality: logFactorial, logNcomb, Perm, perm, Comb, comb.
March 29, 2016
On Monday, 28 March 2016 at 15:30:56 UTC, Timon Gehr wrote:
> Regarding ideas:
> For each range, there should probably be a numeric function computing the length of that range. (e.g. here, binomial corresponds to combinations, there should be factorial corresponding to permutations etc.)
>
> This table might provide some inspiration:

Thanks a lot for your input and ideas - I will work on it ;-)