MCPcopy Create free account
hub / github.com/numpy/numpy / random_multinomial

Function random_multinomial

numpy/random/src/distributions/distributions.c:1699–1716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1697}
1698
1699void random_multinomial(bitgen_t *bitgen_state, RAND_INT_TYPE n,
1700 RAND_INT_TYPE *mnix, double *pix, npy_intp d,
1701 binomial_t *binomial) {
1702 double remaining_p = 1.0;
1703 npy_intp j;
1704 RAND_INT_TYPE dn = n;
1705 for (j = 0; j < (d - 1); j++) {
1706 mnix[j] = random_binomial(bitgen_state, pix[j] / remaining_p, dn, binomial);
1707 dn = dn - mnix[j];
1708 if (dn <= 0) {
1709 break;
1710 }
1711 remaining_p -= pix[j];
1712 }
1713 if (dn > 0) {
1714 mnix[d - 1] = dn;
1715 }
1716}

Callers 1

Calls 1

random_binomialFunction · 0.85

Tested by

no test coverage detected