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

Function random_geometric_inversion

numpy/random/src/distributions/distributions.c:980–990  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978}
979
980int64_t random_geometric_inversion(bitgen_t *bitgen_state, double p) {
981 double z = ceil(-random_standard_exponential(bitgen_state) / npy_log1p(-p));
982 /*
983 * The constant 9.223372036854776e+18 is the smallest double that is
984 * larger than INT64_MAX.
985 */
986 if (z >= 9.223372036854776e+18) {
987 return INT64_MAX;
988 }
989 return (int64_t) z;
990}
991
992int64_t random_geometric(bitgen_t *bitgen_state, double p) {
993 if (p >= 0.333333333333333333333333) {

Callers 1

random_geometricFunction · 0.85

Calls 3

ceilFunction · 0.85
npy_log1pFunction · 0.85

Tested by

no test coverage detected