Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401]

(no description)

File Size: 237 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Binomial:: (5 methods):
  distribution()
  range()
  negative()
  inverse()
  calculateCumulativeBinomial()


Class: Binomial  - X-Ref

distribution($value, $trials, $probability, $cumulative)   X-Ref
BINOMDIST.

Returns the individual term binomial distribution probability. Use BINOMDIST in problems with
a fixed number of tests or trials, when the outcomes of any trial are only success or failure,
when trials are independent, and when the probability of success is constant throughout the
experiment. For example, BINOMDIST can calculate the probability that two of the next three
babies born are male.

param: mixed $value Integer number of successes in trials
param: mixed $trials Integer umber of trials
param: mixed $probability Probability of success on each trial as a float
param: mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
return: array|float|string

range($trials, $probability, $successes, $limit = null)   X-Ref
BINOM.DIST.RANGE.

Returns returns the Binomial Distribution probability for the number of successes from a specified number
of trials falling into a specified range.

param: mixed $trials Integer number of trials
param: mixed $probability Probability of success on each trial as a float
param: mixed $successes The integer number of successes in trials
param: mixed $limit Upper limit for successes in trials as null, or an integer
return: array|float|string

negative($failures, $successes, $probability)   X-Ref
NEGBINOMDIST.

Returns the negative binomial distribution. NEGBINOMDIST returns the probability that
there will be number_f failures before the number_s-th success, when the constant
probability of a success is probability_s. This function is similar to the binomial
distribution, except that the number of successes is fixed, and the number of trials is
variable. Like the binomial, trials are assumed to be independent.

param: mixed $failures Number of Failures as an integer
param: mixed $successes Threshold number of Successes as an integer
param: mixed $probability Probability of success on each trial as a float
return: array|float|string The result, or a string containing an error

inverse($trials, $probability, $alpha)   X-Ref
BINOM.INV.

Returns the smallest value for which the cumulative binomial distribution is greater
than or equal to a criterion value

param: mixed $trials number of Bernoulli trials as an integer
param: mixed $probability probability of a success on each trial as a float
param: mixed $alpha criterion value as a float
return: array|int|string

calculateCumulativeBinomial(int $value, int $trials, float $probability)   X-Ref

return: float|int