MCPcopy Create free account
hub / github.com/crawl/crawl / binomial

Function binomial

crawl-ref/source/random.cc:391–399  ·  view source on GitHub ↗

Sample from a binomial distribution. * * This is the number of successes in a sequence of independent trials with * fixed probability. * * @param n_trials The number of trials. * @param trial_prob The numerator of the probability of success of each trial. * If greater than scale, the probability is 1.0. * @param scale The denominator of trial_prob, default 100. * @return

Source from the content-addressed store, hash-verified

389 * @return the number of successes, range [0, n_trials]
390 */
391int binomial(unsigned n_trials, unsigned trial_prob, unsigned scale)
392{
393 int count = 0;
394 for (unsigned i = 0; i < n_trials; ++i)
395 if (::x_chance_in_y(trial_prob, scale))
396 count++;
397
398 return count;
399}
400
401// range [0, 1.0)
402// This uses a technique described by Saito and Matsumoto at

Callers 6

_get_randart_propertiesFunction · 0.85
cast_revivificationFunction · 0.85
knockback_actorMethod · 0.85
_jiyva_mutateFunction · 0.85

Calls 1

x_chance_in_yFunction · 0.85

Tested by

no test coverage detected