binomial_distribution Derived Type

type, public, extends(distribution) :: binomial_distribution

Defines a binomial distribution. The binomial distribution describes the probability p of getting k successes in n independent trials.


Contents


Components

Type Visibility Attributes Name Initial
integer(kind=int32), public :: n

The number of independent trials.

real(kind=real64), public :: p

The success probability for each trial. This parameter must exist on the set [0, 1].


Type-Bound Procedures

procedure, public :: cdf => bd_cdf

  • private pure elemental function bd_cdf(this, x) result(rst)

    Computes the cumulative distribution funtion.

    The CDF for a binomial distribution is given as , which is simply the regularized incomplete beta function.

    Arguments

    Type IntentOptional Attributes Name
    class(binomial_distribution), intent(in) :: this

    The binomial_distribution object.

    real(kind=real64), intent(in) :: x

    The value at which to evaluate the function. This parameter is the number k successes in the n independent trials. As such, this parameter must exist on the set [0, n].

    Return Value real(kind=real64)

    The value of the function.

procedure, public :: mean => bd_mean

  • private pure function bd_mean(this) result(rst)

    Computes the mean of the distribution.

    Arguments

    Type IntentOptional Attributes Name
    class(binomial_distribution), intent(in) :: this

    The binomial_distribution object.

    Return Value real(kind=real64)

    The mean.

procedure, public :: median => bd_median

  • private pure function bd_median(this) result(rst)

    Computes the median of the distribution.

    Arguments

    Type IntentOptional Attributes Name
    class(binomial_distribution), intent(in) :: this

    The binomial_distribution object.

    Return Value real(kind=real64)

    The median.

procedure, public :: mode => bd_mode

  • private pure function bd_mode(this) result(rst)

    Computes the mode of the distribution.

    Arguments

    Type IntentOptional Attributes Name
    class(binomial_distribution), intent(in) :: this

    The binomial_distribution object.

    Return Value real(kind=real64)

    The mode.

procedure, public :: pdf => bd_pdf

  • private pure elemental function bd_pdf(this, x) result(rst)

    Computes the probability mass function.

    The PMF for a binomial distribution is given as .

    Arguments

    Type IntentOptional Attributes Name
    class(binomial_distribution), intent(in) :: this

    The binomial_distribution object.

    real(kind=real64), intent(in) :: x

    The value at which to evaluate the function. This parameter is the number k successes in the n independent trials. As such, this parameter must exist on the set [0, n].

    Return Value real(kind=real64)

    The value of the function.

procedure, public :: standardized_variable => dist_std_var

Computes the standardized variable for the distribution.

  • private pure elemental function dist_std_var(this, x) result(rst)

    Computes the standardized variable for the distribution.

    Arguments

    Type IntentOptional Attributes Name
    class(distribution), intent(in) :: this

    The distribution object.

    real(kind=real64), intent(in) :: x

    The value of interest.

    Return Value real(kind=real64)

    The result.

procedure, public :: variance => bd_variance

  • private pure function bd_variance(this) result(rst)

    Computes the variance of the distribution.

    Arguments

    Type IntentOptional Attributes Name
    class(binomial_distribution), intent(in) :: this

    The binomial_distribution object.

    Return Value real(kind=real64)

    The variance.