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

Function random_binomial

numpy/random/src/distributions/distributions.c:792–813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790}
791
792int64_t random_binomial(bitgen_t *bitgen_state, double p, int64_t n,
793 binomial_t *binomial) {
794 double q;
795
796 if ((n == 0LL) || (p == 0.0f))
797 return 0;
798
799 if (p <= 0.5) {
800 if (p * n <= 30.0) {
801 return random_binomial_inversion(bitgen_state, n, p, binomial);
802 } else {
803 return random_binomial_btpe(bitgen_state, n, p, binomial);
804 }
805 } else {
806 q = 1.0 - p;
807 if (q * n <= 30.0) {
808 return n - random_binomial_inversion(bitgen_state, n, q, binomial);
809 } else {
810 return n - random_binomial_btpe(bitgen_state, n, q, binomial);
811 }
812 }
813}
814
815double random_noncentral_chisquare(bitgen_t *bitgen_state, double df,
816 double nonc) {

Callers 1

random_multinomialFunction · 0.85

Calls 2

random_binomial_btpeFunction · 0.85

Tested by

no test coverage detected