The OpenD Programming Language

gammaPDF

Computes the gamma probability density function (PDF).

shape values less than 1 are supported when it is a floating point type.

If shape is passed as a size_t type (or a type convertible to that), then the PDF is calculated using the relationship with the poisson distribution (i.e. replacing the gamma function with the factorial).

  1. T gammaPDF(T x, T shape, T scale)
  2. T gammaPDF(T x, size_t shape, T scale)
    @safe pure nothrow @nogc
    T
    gammaPDF
    (
    T
    )
    (
    const T x
    ,
    const size_t shape
    ,
    const T scale = 1
    )
    if (
    isFloatingPoint!T
    )

Parameters

x T

value to evaluate PDF

shape size_t

shape parameter

scale T

scale parameter

Examples

import mir.test: shouldApprox;

2.0.gammaPDF(3.0).shouldApprox == 0.2706706;
2.0.gammaPDF(3.0, 4.0).shouldApprox == 0.01895408;
// Calling with `size_t` uses factorial function instead of gamma, but
// produces same results
2.0.gammaPDF(3).shouldApprox == 2.0.gammaPDF(3.0);
2.0.gammaPDF(3, 4.0).shouldApprox == 2.0.gammaPDF(3.0, 4.0);

See Also

Meta