Processing math: 100%

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 F(k,n,p)=I1p(nk,1+k), 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 :: defined_range => bd_range

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

    Gets the defined range for the distribution.

    Arguments

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

    The binomial_distribution object.

    Return Value real(kind=real64), dimension(2)

    The defined range of the probability distributions [0, infinity). As using a value of infinity may cause issue, this routine returns huge(0.0d0) instead.

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 f(k,n,p)=n!k!(nk!)pk(1p)nk.

    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 :: recenter => bd_recenter

  • private subroutine bd_recenter(this, x)

    Recenters the distribution about the supplied value.

    Arguments

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

    The binomial_distribution object.

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

    The value about which to recenter.

procedure, public :: standardized_variable => dist_std_var

  • 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.