Socket
Book a DemoInstallSign in
Socket

multinomial

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multinomial

Multinomial coefficients

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
3
Maintainers
2
Weekly downloads
 
Created
Source

multinomial

Computes multinomial coefficients. Also allows efficiently computing entire sets of binomial and multinomial coefficients in one go.

Example


var multi = require("multinomial")

console.log(multi(7, 4, 2)) // Prints: 25740

Install

npm install multinomial

require("multinomial")(a0, a1, ... )

Computes the multinomial coefficient, or in other words:

     /                     \
    |  a0 + a1 + a2 + ...   |
    |                       |
    | a0   a1    a2   ...   |
     \                     /

Note You can also pass an array as input instead of a list of arguments.

require("multinomial").multinomials(n, d)

Returns an object containing:

  • counts An array containing "histograms" of the d numbers (each histogram sums to n).
  • coefs An array with the multinomial coefficients corresponding to the histograms in `counts'.

Note that the order in which the coefficients are returned is fixed, but that it is not recommended to rely on this (other orders might have benefits over this one, so it might change in the future).

require("multinomial").binomials(n)

Conceptually the same as require("multinomial").multinomials(n, 2), but just returns the list of coefficients. In this case, the order of the coefficients is guaranteed. In particular, the i-th coefficient gives the number of ways in which one can pick i out of n positions.

Credit

(c) 2013 Mikola Lysenko. MIT License

Keywords

multinomial

FAQs

Package last updated on 01 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts