Package Exports
- multinomial-ln
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (multinomial-ln) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
multinomial-ln
log(multinomial coefficient) from logs all the way down
install
npm install multinomial-lnexample
var multinomialLn = require('multinomial-ln')
Math.round(Math.exp(multinomialLn([3, 5, 3, 5, 5]))
// 821292151680You can also work completely in log.
multinomialLn([1, 5, 7, 5, 5, 1, 2, 3])
// 106.60573852903470As the factorial function used to generate these log-multinomial coefficients is approximate, results like this one are not exact, although respecting the magnitude of this value (e^106.6), the actual value is plenty close. Keep this in mind.
about
Multinomial coefficients can quickly become huge, even for small counts and small numbers of terms. This makes the impossible to compute without a bit of cleverness. For example, the multinomial coefficient for [ 6, 4, 5, 3, 3 ] will overflow the vanilla node multinomial coefficient library. Where exact results are not required (a big number library is not required to calculate these) they can be generated using log terms for the factorials that underly them. That is what this library implements. As such it is probably most-useful in projects focused on probabilities and statistics.
license
MIT
