fsml_dst Module

Statistical distribution module. Common parameterisation and mathematical notation is used. Additional parameters are sometimes added to enhance functionality.


Uses

  • module~~fsml_dst~~UsesGraph module~fsml_dst fsml_dst module~fsml_con fsml_con module~fsml_dst->module~fsml_con module~fsml_err fsml_err module~fsml_dst->module~fsml_err module~fsml_ini fsml_ini module~fsml_dst->module~fsml_ini module~fsml_con->module~fsml_ini module~fsml_err->module~fsml_con module~fsml_err->module~fsml_ini module~fsml_utl fsml_utl module~fsml_err->module~fsml_utl iso_fortran_env iso_fortran_env module~fsml_ini->iso_fortran_env stdlib_linalg stdlib_linalg module~fsml_ini->stdlib_linalg module~fsml_utl->module~fsml_ini

Used by

  • module~~fsml_dst~~UsedByGraph module~fsml_dst fsml_dst module~fsml fsml module~fsml->module~fsml_dst module~fsml_tst fsml_tst module~fsml->module~fsml_tst module~fsml_tst->module~fsml_dst

Functions

public impure function f_dst_chi2_cdf(x, df, loc, scale, tail) result(p)

Impure wrapper function for f_dst_chi2_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in), optional :: loc

location parameter

real(kind=wp), intent(in), optional :: scale

scale parameter

character(len=*), intent(in), optional :: tail

tail options

Return Value real(kind=wp)

resulting CDF value

public elemental function f_dst_chi2_cdf_core(x, df, loc, scale, tail) result(p)

Cumulative distribution function for the chi-squared distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in) :: loc

location parameter

real(kind=wp), intent(in) :: scale

scale parameter

character(len=*), intent(in) :: tail

tail options

Return Value real(kind=wp)

resulting CDF value

public impure function f_dst_chi2_pdf(x, df, loc, scale) result(fx)

Impure wrapper function for f_dst_chi2_pdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in), optional :: loc

location parameter

real(kind=wp), intent(in), optional :: scale

scale parameter

Return Value real(kind=wp)

resulting PDF value

public elemental function f_dst_chi2_pdf_core(x, df, loc, scale) result(fx)

Probability density function for the chi-squared distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in) :: loc

location parameter

real(kind=wp), intent(in) :: scale

scale parameter

Return Value real(kind=wp)

resulting PDF value

public impure function f_dst_chi2_ppf(p, df, loc, scale) result(x)

Impure wrapper function for f_dst_chi2_ppf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 and 1.0

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in), optional :: loc

location parameter

real(kind=wp), intent(in), optional :: scale

scale parameter

Return Value real(kind=wp)

sample position

public elemental function f_dst_chi2_ppf_core(p, df, loc, scale) result(x)

Percent point function/quantile functionfor the chi-squared distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 and 1.0

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in) :: loc

location parameter

real(kind=wp), intent(in) :: scale

scale parameter

Return Value real(kind=wp)

sample position

public impure function f_dst_exp_cdf(x, lambda, loc, tail) result(p)

Impure wrapper function for f_dst_exp_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in), optional :: lambda

lambda parameter, beta(scale) = 1/lambda = mu/mean

real(kind=wp), intent(in), optional :: loc

location parameter

character(len=*), intent(in), optional :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public elemental function f_dst_exp_cdf_core(x, lambda, loc, tail) result(p)

Cumulative distribution function for exponential distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: lambda

lambda parameter, beta(scale) = 1/lambda = mu/mean

real(kind=wp), intent(in) :: loc

location parameter

character(len=*), intent(in) :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public impure function f_dst_exp_pdf(x, lambda, loc) result(fx)

Impure wrapper function for f_dst_exp_pdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in), optional :: lambda

lambda parameter, beta(scale) = 1/lambda = mu/mean

real(kind=wp), intent(in), optional :: loc

location parameter

Return Value real(kind=wp)

public elemental function f_dst_exp_pdf_core(x, lambda, loc) result(fx)

Probability density function for exponential distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: lambda

lambda parameter, beta(scale) = 1/lambda = mu/mean

real(kind=wp), intent(in) :: loc

location parameter

Return Value real(kind=wp)

public impure function f_dst_exp_ppf(p, lambda, loc) result(x)

Impure wrapper function for f_dst_exp_ppf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in), optional :: lambda

lambda parameter, beta(scale) = 1/lambda = mu/mean

real(kind=wp), intent(in), optional :: loc

location parameter

Return Value real(kind=wp)

sample position

public elemental function f_dst_exp_ppf_core(p, lambda, loc) result(x)

Percent point function/quantile function for exponential distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in) :: lambda

lambda parameter, beta(scale) = 1/lambda = mu/mean

real(kind=wp), intent(in) :: loc

location parameter

Return Value real(kind=wp)

sample position

public impure function f_dst_f_cdf(x, d1, d2, loc, scale, tail) result(p)

Impure wrapper function for f_dst_f_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: d1

numerator degrees of freedom

real(kind=wp), intent(in) :: d2

denominator degrees of freedom

real(kind=wp), intent(in), optional :: loc

location parameter

real(kind=wp), intent(in), optional :: scale

scale parameter

character(len=*), intent(in), optional :: tail

tail option

Return Value real(kind=wp)

output probability

public elemental function f_dst_f_cdf_core(x, d1, d2, loc, scale, tail) result(p)

Cumulative density function for the F distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: d1

numerator degrees of freedom

real(kind=wp), intent(in) :: d2

denominator degrees of freedom

real(kind=wp), intent(in) :: loc

location parameter

real(kind=wp), intent(in) :: scale

scale parameter

character(len=*), intent(in) :: tail

tail option

Return Value real(kind=wp)

output probability

public impure function f_dst_f_pdf(x, d1, d2, loc, scale) result(fx)

Impure wrapper function for f_dst_f_pdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: d1

numerator degrees of freedom

real(kind=wp), intent(in) :: d2

denominator degrees of freedom

real(kind=wp), intent(in), optional :: loc

location parameter

real(kind=wp), intent(in), optional :: scale

scale parameter

Return Value real(kind=wp)

public elemental function f_dst_f_pdf_core(x, d1, d2, loc, scale) result(fx)

Probability density function for the F distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: d1

numerator degrees of freedom

real(kind=wp), intent(in) :: d2

denominator degrees of freedom

real(kind=wp), intent(in) :: loc

location parameter

real(kind=wp), intent(in) :: scale

scale parameter

Return Value real(kind=wp)

public impure function f_dst_f_ppf(p, d1, d2, loc, scale) result(x)

Impure wrapper function for f_dst_f_ppf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability (0.0 < p < 1.0)

real(kind=wp), intent(in) :: d1

numerator degrees of freedom

real(kind=wp), intent(in) :: d2

denominator degrees of freedom

real(kind=wp), intent(in), optional :: loc

location parameter

real(kind=wp), intent(in), optional :: scale

scale parameter

Return Value real(kind=wp)

public elemental function f_dst_f_ppf_core(p, d1, d2, loc, scale) result(x)

Percent point function / quantile function for the F distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability (0.0 < p < 1.0)

real(kind=wp), intent(in) :: d1

numerator degrees of freedom

real(kind=wp), intent(in) :: d2

denominator degrees of freedom

real(kind=wp), intent(in) :: loc

location parameter

real(kind=wp), intent(in) :: scale

scale parameter

Return Value real(kind=wp)

public impure function f_dst_gamma_cdf(x, alpha, beta, loc, tail) result(p)

Impure wrapper function for f_dst_gamma_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in), optional :: alpha

shape parameter

real(kind=wp), intent(in), optional :: beta

scale parameter

real(kind=wp), intent(in), optional :: loc

location parameter

character(len=*), intent(in), optional :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public elemental function f_dst_gamma_cdf_core(x, alpha, beta, loc, tail) result(p)

Cumulative distribution function for gamma distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: alpha

shape parameter

real(kind=wp), intent(in) :: beta

scale parameter

real(kind=wp), intent(in) :: loc

location parameter

character(len=*), intent(in) :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public impure function f_dst_gamma_pdf(x, alpha, beta, loc) result(fx)

Impure wrapper function for f_dst_gamma_pdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in), optional :: alpha

shape parameter

real(kind=wp), intent(in), optional :: beta

scale parameter

real(kind=wp), intent(in), optional :: loc

location parameter

Return Value real(kind=wp)

public elemental function f_dst_gamma_pdf_core(x, alpha, beta, loc) result(fx)

Probability density function for gamma distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: alpha

shape parameter

real(kind=wp), intent(in) :: beta

scale parameter

real(kind=wp), intent(in) :: loc

location parameter

Return Value real(kind=wp)

public impure function f_dst_gamma_ppf(p, alpha, beta, loc) result(x)

Impure wrapper function for f_dst_gamma_ppf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in), optional :: alpha

shape parameter

real(kind=wp), intent(in), optional :: beta

scale parameter

real(kind=wp), intent(in), optional :: loc

location parameter

Return Value real(kind=wp)

sample position

public elemental function f_dst_gamma_ppf_core(p, alpha, beta, loc) result(x)

Percent point function/quantile function for gamma distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in) :: alpha

shape parameter

real(kind=wp), intent(in) :: beta

scale parameter

real(kind=wp), intent(in) :: loc

location parameter

Return Value real(kind=wp)

sample position

public impure function f_dst_gpd_cdf(x, xi, mu, sigma, tail) result(p)

Impure wrapper function for f_dst_gpd_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: xi

distribution shape parameter

real(kind=wp), intent(in), optional :: mu

distribution location

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (must be positive)

character(len=*), intent(in), optional :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public elemental function f_dst_gpd_cdf_core(x, xi, mu, sigma, tail) result(p)

Cumulative distribution function for generalised pareto distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: xi

distribution shape parameter

real(kind=wp), intent(in) :: mu

distribution location

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (must be positive)

character(len=*), intent(in) :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public impure function f_dst_gpd_pdf(x, xi, mu, sigma) result(fx)

Impure wrapper function for f_dst_gpd_pdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: xi

distribution shape parameter

real(kind=wp), intent(in), optional :: mu

distribution location

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (must be positive)

Return Value real(kind=wp)

public elemental function f_dst_gpd_pdf_core(x, xi, mu, sigma) result(fx)

Probability density function for generalised pareto distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: xi

distribution shape parameter

real(kind=wp), intent(in) :: mu

distribution location

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (must be positive)

Return Value real(kind=wp)

public impure function f_dst_gpd_ppf(p, xi, mu, sigma) result(x)

Impure wrapper function for f_dst_gpd_ppf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in), optional :: xi

distribution shape parameter

real(kind=wp), intent(in), optional :: mu

distribution location

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (must be positive)

Return Value real(kind=wp)

sample position

public elemental function f_dst_gpd_ppf_core(p, xi, mu, sigma) result(x)

Percent point function/quantile function for generalised pareto distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in) :: xi

distribution shape parameter

real(kind=wp), intent(in) :: mu

distribution location

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (must be positive)

Return Value real(kind=wp)

sample position

public impure function f_dst_norm_cdf(x, mu, sigma, tail) result(p)

Impure wrapper function for f_dst_norm_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in), optional :: mu

distribution location (mean)

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (standard deviation)

character(len=*), intent(in), optional :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public elemental function f_dst_norm_cdf_core(x, mu, sigma, tail) result(p)

Cumulative distribution function for normal distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: mu

distribution location (mean)

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (standard deviation)

character(len=*), intent(in) :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public impure function f_dst_norm_pdf(x, mu, sigma) result(fx)

Impure wrapper function for f_dst_norm_pdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in), optional :: mu

distribution location (mean)

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (standard deviation)

Return Value real(kind=wp)

public elemental function f_dst_norm_pdf_core(x, mu, sigma) result(fx)

Probability density function for normal distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: mu

distribution location (mean)

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (standard deviation)

Return Value real(kind=wp)

public impure function f_dst_norm_ppf(p, mu, sigma) result(x)

Impure wrapper function for f_dst_norm_ppf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in), optional :: mu

distribution location (mean)

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (standard deviation)

Return Value real(kind=wp)

sample position

public elemental function f_dst_norm_ppf_core(p, mu, sigma) result(x)

Percent point function/quantile function for normal distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in) :: mu

distribution location (mean)

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (standard deviation)

Return Value real(kind=wp)

sample position

public impure function f_dst_t_cdf(x, df, mu, sigma, tail) result(p)

Impure wrapper function for f_dst_t_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in), optional :: mu

distribution location (mean)

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (standard deviation)

character(len=*), intent(in), optional :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public elemental function f_dst_t_cdf_core(x, df, mu, sigma, tail) result(p)

Cumulative distribution function for student t distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in) :: mu

distribution location (mean)

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (standard deviation)

character(len=*), intent(in) :: tail

tail options

Return Value real(kind=wp)

returned probability integral

public impure function f_dst_t_pdf(x, df, mu, sigma) result(fx)

Impure wrapper function for f_dst_t_pdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in), optional :: mu

distribution location (~mean)

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (~standard deviation)

Return Value real(kind=wp)

public elemental function f_dst_t_pdf_core(x, df, mu, sigma) result(fx)

Probability density function for student t distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in) :: mu

distribution location (~mean)

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (~standard deviation)

Return Value real(kind=wp)

public impure function f_dst_t_ppf(p, df, mu, sigma) result(x)

Impure wrapper function for f_dst_t_ppf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in), optional :: mu

distribution location (mean)

real(kind=wp), intent(in), optional :: sigma

distribution dispersion/scale (standard deviation)

Return Value real(kind=wp)

sample position

public elemental function f_dst_t_ppf_core(p, df, mu, sigma) result(x)

Percent point function/quantile function for t distribution.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: p

probability between 0.0 - 1.0

real(kind=wp), intent(in) :: df

degrees of freedom

real(kind=wp), intent(in) :: mu

distribution location (mean)

real(kind=wp), intent(in) :: sigma

distribution dispersion/scale (standard deviation)

Return Value real(kind=wp)

sample position

private elemental function f_dst_betai_core(x, a, b) result(betai)

Computes the regularised incomplete beta function. beta_inc and beta_cf algorithms are based on several public domain Fortran and C code, Lentz's algorithm (1976), and modified to use 2008+ intrinsics.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

upper limit of integral

real(kind=wp), intent(in) :: a

shape parameters for beta dist.

real(kind=wp), intent(in) :: b

shape parameters for beta dist.

Return Value real(kind=wp)

regularised incomplete beta function

private elemental function f_dst_gammai_core(a, x) result(p)

Incomplete gamma function. Needed by gamma and chi-squared cdf. Uses Fortran 2008+ intrinsics.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: a
real(kind=wp), intent(in) :: x

Return Value real(kind=wp)