Introduction to distrib
=======================

Package distrib contains a set of functions for making probability computations on both discrete and continuous univariate models.

What follows is a short reminder of basic probabilistic related definitions.

Let f(x) be the DENSITY FUNCTION of an absolute continuous random variable X. The DISTRIBUTION FUNCTION is defined as

                            x
                           /
                           [
                    F(x) = I     f(u) du
                           ]
                           /
                            minf

which equals the probability Pr(X <= x) .

The MEAN value is a localization parameter and is defined as

                          inf
                         /
                         [
                E[X]  =  I   x f(x) dx
                         ]
                         /
                          minf

The VARIANCE is a measure of variation,

                      inf
                     /
                     [                    2
              V[X] = I     f(x) (x - E[X])  dx
                     ]
                     /
                      minf

which is a positive real number. The square root of the variance is the STANDARD DEVIATION, D[X]=sqrt(V[X]) , and it is another measure of variation.

The SKEWNESS COEFFICIENT is a measure of non-symmetry,

                      inf
                     /
                 1   [                    3
       SK[X] = ----- I     f(x) (x - E[X])  dx
                   3 ]
               D[X]  /
                      minf

And the KURTOSIS COEFFICIENT measures the peakedness of the distribution,

                      inf
                     /
                 1   [                    4
       KU[X] = ----- I     f(x) (x - E[X])  dx - 3
                   4 ]
               D[X]  /
                      minf

If X is gaussian, KU[X]=0. In fact, both skewness and kurtosis are shape parameters used to measure the non--gaussianity of a distribution.

If the random variable X is discrete, the density, or PROBABILITY, function f(x) takes positive values within certain countable set of numbers x_i, and zero elsewhere. In this case, the distribution function is

                            ====
                            \
                     F(x) =  >    f(x )
                            /        i
                            ====
                           x <= x
                            i

The mean, variance, standard deviation, skewness coefficient and kurtosis coefficient take the form

               ====
               \
        E[X] =  >  x  f(x ) ,
               /    i    i
               ====
                x
                 i

                ====
                \                     2
        V[X] =   >    f(x ) (x - E[X])  ,
                /        i    i
                ====
                 x
                  i

               D[X] = sqrt(V[X]),

                          ====
                   1      \                     3
       SK[X] =  -------    >    f(x ) (x - E[X])
                D[X]^3    /        i    i
                          ====
                           x
                            i

                          ====
                   1      \                     4
       KU[X] =  -------    >    f(x ) (x - E[X])   - 3 ,
                D[X]^4    /        i    i
                          ====
                           x
                            i

respectively.

There is a naming convention in package distrib. Every function name has two parts, the first one makes reference to the function or parameter we want to calculate,

     Functions:
        Density function            (pdf_*)
        Distribution function       (cdf_*)
        Quantile                    (quantile_*)
        Mean                        (mean_*)
        Variance                    (var_*)
        Standard deviation          (std_*)
        Skewness coefficient        (skewness_*)
        Kurtosis coefficient        (kurtosis_*)
        Random variate              (random_*)

The second part is an explicit reference to the probabilistic model,

     Continuous distributions:
        Normal              (*normal)
        Student             (*student_t)
        Chi^2               (*chi2)
        Noncentral Chi^2    (*noncentral_chi2)
        F                   (*f)
        Exponential         (*exp)
        Lognormal           (*lognormal)
        Gamma               (*gamma)
        Beta                (*beta)
        Continuous uniform  (*continuous_uniform)
        Logistic            (*logistic)
        Pareto              (*pareto)
        Weibull             (*weibull)
        Rayleigh            (*rayleigh)
        Laplace             (*laplace)
        Cauchy              (*cauchy)
        Gumbel              (*gumbel)

     Discrete distributions:
        Binomial             (*binomial)
        Poisson              (*poisson)
        Bernoulli            (*bernoulli)
        Geometric            (*geometric)
        Discrete uniform     (*discrete_uniform)
        hypergeometric       (*hypergeometric)
        Negative binomial    (*negative_binomial)
        Finite discrete      (*general_finite_discrete)

For example, pdf_student_t(x,n) is the density function of the Student distribution with N degrees of freedom, std_pareto(a,b) is the standard deviation of the Pareto distribution with parameters A and B and kurtosis_poisson(m) is the kurtosis coefficient of the Poisson distribution with mean M.

In order to make use of package distrib you need first to load it by typing

     (%i1) load("distrib")$

For comments, bugs or suggestions, please contact the author at 'RIOTORTO AT YAHOO DOT COM'.

Categories: Statistical functions Share packages Package distrib

Functions and Variables for continuous distributions
====================================================

Maxima knows the following kinds of continuous distributions.

Normal Random Variable
----------------------

Normal random variables (also called Gaussian) is denoted by Normal(m, s) where m is the mean and s > 0 is the standard deviation.

 -- Function: pdf_normal (X,M,S)
     Returns the value at X of the density function of a Normal(m, s) random variable, with s>0. To make use of this function, write first load("distrib").

     The pdf is

                                           2
                                    (x - m)
                                  - --------
                                         2
                                      2 s
                                %e
                f(x, m, s) = -------------------
                             sqrt(2) sqrt(%pi) s

     Categories: Package distrib

 -- Function: cdf_normal (X,M,S)
     Returns the value at X of the distribution function of a Normal(m, s) random variable, with s>0. This function is defined in terms of Maxima's built-in error function erf.

     The cdf can be written analytically:

                                  x - m
                            erf(---------)
                                sqrt(2) s    1
               F(x, m, s) = -------------- + -
                                  2          2

          (%i1) load ("distrib")$

          (%i2) cdf_normal(x,m,s);
                                       x - m
                                 erf(---------)
                                     sqrt(2) s    1
          (%o2)                  -------------- + -
                                       2          2

     See also erf

     Categories: Package distrib

 -- Function: quantile_normal (Q,M,S)
     Returns the Q-quantile of a Normal(m, s) random variable, with s>0; in other words, this is the inverse of cdf_normal Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

          (%i1) load ("distrib")$

          (%i2) quantile_normal(95/100,0,1);
                                                   9
          (%o2)                sqrt(2) inverse_erf(--)
                                                   10

          (%i3) float(%);
          (%o3)                   1.644853626951472

     Categories: Package distrib

 -- Function: mean_normal (M,S)
     Returns the mean of a Normal(m, s) random variable, with s>0. To make use of this function, write first load("distrib").

     The mean is

                                       E[X] = m

     Categories: Package distrib

 -- Function: var_normal (M,S)
     Returns the variance of a Normal(m, s) random variable, with s>0. To make use of this function, write first load("distrib").

     The variance is

                                               2
                                       V[X] = s

     Categories: Package distrib

 -- Function: std_normal (M,S)
     Returns the standard deviation of a Normal(m, s) random variable, with s>0, namely S. To make use of this function, write first load("distrib").

     The standard deviation is

                                       D[X] = s

     Categories: Package distrib

 -- Function: skewness_normal (M,S)
     Returns the skewness coefficient of a Normal(m, s) random variable, with s>0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                       SK[X] = 0

     Categories: Package distrib

 -- Function: kurtosis_normal (M,S)
     Returns the kurtosis coefficient of a Normal(m, s) random variable, with s>0, which is always equal to 0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                       SK[X] = 0

     Categories: Package distrib

 -- Function: random_normal (M,S)
     random_normal (M,S,N)

     Returns a Normal(m, s) random variate, with s>0. Calling random_normal with a third argument N, a random sample of size N will be simulated.

     This is an implementation of the Box-Mueller algorithm, as described in Knuth, D.E. (1981) SEMINUMERICAL ALGORITHMS. THE ART OF COMPUTER PROGRAMMING. Addison-Wesley.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Student's t Random Variable
---------------------------

Student's t random variable is denoted by t(n) where n is the degrees of freedom with n > 0.  If Z is a Normal(0, 1) variable and V is an independent chi^2 random variable with n degress of freedom, then

Z/sqrt(V/n)

has a Student's t-distribution with n degrees of freedom.

 -- Function: pdf_student_t (X,N)
     Returns the value at X of the density function of a Student random variable t(n), with n>0 degrees of freedom. To make use of this function, write first load("distrib").

     The pdf is

                                               (- n) - 1
                                         2     ---------
                                n + 1   x          2
                          gamma(-----) (-- + 1)
                                  2     n
                f(x, n) = ------------------------------
                                            n
                            sqrt(%pi) gamma(-) sqrt(n)
                                            2

     (sqrt(n)*beta(1/2,n/2))^(-1) (1+x^2/n)^(-(n+1)/2)

     Categories: Package distrib

 -- Function: cdf_student_t (X,N)
     Returns the value at X of the distribution function of a Student random variable t(n), with n>0 degrees of freedom.

     The cdf is

                   [ 1-1/2*I_t(n/2, 1/2)  x >= 0
          F(x,n) = [
                   [ 1/2*I_t(n/2, 1/2)    x < 0

     where t = n/(n+x^2) and I_t(a,b) is the beta_incomplete_regularized function.

          (%i1) load ("distrib")$

          (%i2) cdf_student_t(1/2, 7/3);
                                                      7  1  28
                          beta_incomplete_regularized(-, -, --)
                                                      6  2  31
          (%o2)       1 - -------------------------------------
                                            2

          (%i3) float(%);
          (%o3)                  0.6698450596140415

     Categories: Package distrib

 -- Function: quantile_student_t (Q,N)
     Returns the Q-quantile of a Student random variable t(n), with n>0; in other words, this is the inverse of cdf_student_t. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_student_t (N)
     Returns the mean of a Student random variable t(n), with n>0. To make use of this function, write first load("distrib").

     The mean is

                                       E[X] = 0

     Categories: Package distrib

 -- Function: var_student_t (N)
     Returns the variance of a Student random variable t(n), with n>2.

     The variance is

                                              n
                                     V[X] = -----
                                            n - 2

          (%i1) load ("distrib")$

          (%i2) var_student_t(n);
                                          n
          (%o2)                         -----
                                        n - 2

     Categories: Package distrib

 -- Function: std_student_t (N)
     Returns the standard deviation of a Student random variable t(n), with n>2. To make use of this function, write first load("distrib").

     The standard deviation is

                                               n
                                 D[X] = sqrt(-----)
                                             n - 2

     Categories: Package distrib

 -- Function: skewness_student_t (N)
     Returns the skewness coefficient of a Student random variable t(n), with n>3, which is always equal to 0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                       SK[X] = 0

     Categories: Package distrib

 -- Function: kurtosis_student_t (N)
     Returns the kurtosis coefficient of a Student random variable t(n), with n>4. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                              6
                                    KU[X] = -----
                                            n - 4

     Categories: Package distrib

 -- Function: random_student_t (N)
     random_student_t (N,M)

     Returns a Student random variate t(n), with n>0. Calling random_student_t with a second argument M, a random sample of size M will be simulated.

     The implemented algorithm is based on the fact that if Z is a normal random variable Normal(0, 1) and S^2 is a chi squared random variable with n degrees of freedom, Chi^2() , then

                                     Z
                           X = -------------
                               /   2  \ 1/2
                               |  S   |
                               | ---  |
                               \  n   /

     is a Student random variable with n degrees of freedom, t(n).

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Noncentral Student's t Random Variable
--------------------------------------

Let ncp be the non-centrality parameter, n be the degrees of freedom for the non-central Student's t random variable.

Then let X be a Normal(n, ncp) and S^2 be an independent chi squared random variable with n degrees of freedom, the random variable U = X/sqrt(S^2/n)

has a non-central Student's t distribution with non-centrality parameter ncp.

 -- Function: pdf_noncentral_student_t (X,N,NCP)
     Returns the value at X of the density function of a noncentral Student random variable nc_t(n, ncp) , with n>0 degrees of freedom and noncentrality parameter ncp. To make use of this function, write first load("distrib").

     The pdf is

                                     2
                                   mu          (- n) - 1
                                 - ---         ---------
                                    2    2         2
                               %e      (x  + 1)          (B(x, n, mu) + An(x, n, mu))
          f(x;n,mu) =          -------------------------------------------------
                                                   1  n
                                              beta(-, -) sqrt(n)
                                                   2  2

     where

                                                  2  2
                                 n + 1    1     mu  x
           A(x, n, mu) = %f    ([-----], [-], ----------)
                           1, 1    2      2       2
                                              2 (x  + n)

                                                             2  2
                                            n        3     mu  x           n
                         sqrt(2) mu %f    ([- + 1], [-], ----------) gamma(- + 1) x
                                      1, 1  2        2       2             2
                                                         2 (x  + n)
           B(x, n, mu) = ----------------------------------------------------------
                                               n + 1        2
                                         gamma(-----) sqrt(x  + n)
                                                 2

     and mu is the non-centrality parameter ncp.

     Sometimes an extra work is necessary to get the final result.

          (%i1) load ("distrib")$

          (%i2) expand(pdf_noncentral_student_t(3,5,0.1));
          rat: replaced 0.01889822365046136 by 15934951/843198350 = 0.01889822365046136

          rat: replaced -8.734356480209641 by -294697965/33740089 = -8.734356480209641

          rat: replaced 4.136255165816327 by 51033443/12338079 = 4.136255165816332

          rat: replaced 1.08061432164203 by 56754827/52520891 = 1.08061432164203

          rat: replaced 0.0565127306411839 by 5608717/99246965 = 0.05651273064118384

          rat: replaced -300.8069396896258 by -79782423/265228 = -300.8069396896256

          rat: replaced 160.6269176184973 by 178374907/1110492 = 160.626917618497
                                     7/2                         7/2
                0.04296414417400905 5      1.323650307289301e-6 5
          (%o2) ------------------------ + -------------------------
                   3/2   5/2                       sqrt(%pi)
                  2    14    sqrt(%pi)
                                                                        7/2
                                                   1.94793720435093e-4 5
                                                 + ------------------------
                                                             %pi

          (%i3) float(%);
          (%o3)                  0.02080593159405671

     Categories: Package distrib

 -- Function: cdf_noncentral_student_t (X,N,NCP)
     Returns the value at X of the distribution function of a noncentral Student random variable nc_t(n, ncp) , with n>0 degrees of freedom and noncentrality parameter ncp. This function has no closed form and it is numerically computed.

          (%i1) load ("distrib")$

          (%i2) cdf_noncentral_student_t(-2,5,-5);
          (%o2)                   0.995203009331975

     Categories: Package distrib

 -- Function: quantile_noncentral_student_t (Q,N,NCP)
     Returns the Q-quantile of a noncentral Student random variable nc_t(n, ncp) , with n>0 degrees of freedom and noncentrality parameter ncp; in other words, this is the inverse of cdf_noncentral_student_t. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_noncentral_student_t (N,NCP)
     Returns the mean of a noncentral Student random variable nc_t(n, ncp) , with n>1 degrees of freedom and noncentrality parameter ncp. To make use of this function, write first load("distrib").

     The mean is

                             n - 1
                    mu gamma(-----) sqrt(n)
                               2
          E[X] =    -----------------------
                                     n
                       sqrt(2) gamma(-)
                                     2

     where mu is the noncentrality parameter ncp.

          (%i1) load ("distrib")$

          (%i2) mean_noncentral_student_t(df,k);
                                    df - 1
                              gamma(------) sqrt(df) k
                                      2
          (%o2)               ------------------------
                                               df
                                 sqrt(2) gamma(--)
                                               2

     Categories: Package distrib

 -- Function: var_noncentral_student_t (N,NCP)
     Returns the variance of a noncentral Student random variable nc_t(n, ncp) , with n>2 degrees of freedom and noncentrality parameter ncp. To make use of this function, write first load("distrib").

     The variance is

                                       2 n - 1       2
                         2        gamma (-----) n ncp
                   n (ncp  + 1)            2
          V[X] =   ------------ - --------------------
                      n - 2                  2 n
                                      2 gamma (-)
                                               2

     where mu is the noncentrality parameter ncp.

     Categories: Package distrib

 -- Function: std_noncentral_student_t (N,NCP)
     Returns the standard deviation of a noncentral Student random variable nc_t(n, ncp) , with n>2 degrees of freedom and noncentrality parameter ncp. To make use of this function, write first load("distrib").

     The standard deviation is

                                       2 n - 1       2
                              2        gamma (-----) n ncp
                        n (ncp  + 1)            2
          D[X] =   sqrt(------------ - --------------------)
                           n - 2                  2 n
                                           2 gamma (-)
                                                    2

     Categories: Package distrib

 -- Function: skewness_noncentral_student_t (N,NCP)
     Returns the skewness coefficient of a noncentral Student random variable nc_t(n, ncp) , with n>3 degrees of freedom and noncentrality parameter ncp. To make use of this function, write first load("distrib").

     If U is a non-central Student's t random variable with n degrees of freedom and a noncentrality parameter mu , the skewness is

          SK[U] =
                                               2
                    n - 1           n (2 n + mu  - 3)
          (mu gamma(-----) sqrt(n) (-----------------
                      2              (n - 3) (n - 2)
                                2      2 n - 1
                   2          mu  gamma (-----) n
                (mu  + 1) n                2
           - 2 (----------- - -------------------)))
                   n - 2                 2 n
                                  2 gamma (-)
                                           2
                                              2      2 n - 1
                                 2          mu  gamma (-----) n
                          n   (mu  + 1) n                2      3/2
          /(sqrt(2) gamma(-) (----------- - -------------------)   )
                          2      n - 2                 2 n
                                                2 gamma (-)
                                                         2

     Categories: Package distrib

 -- Function: kurtosis_noncentral_student_t (N,NCP)
     Returns the kurtosis coefficient of a noncentral Student random variable nc_t(n, ncp) , with n>4 degrees of freedom and noncentrality parameter ncp. To make use of this function, write first load("distrib").

     If U is a non-central Student's t random variable with n degrees of freedom and a noncentrality parameter mu , the kurtosis is

          KU[U] =
              4       2       2
           (mu  + 6 mu  + 3) n       2      2 n - 1
          (-------------------- - (mu  gamma (-----) n
             (n - 4) (n - 2)                    2
                                                               2      2 n - 1
                               2                  2          mu  gamma (-----) n
            n (3 (3 n - 5) + mu  (n + 1))      (mu  + 1) n                2
           (----------------------------- - 3 (----------- - -------------------)))
                   (n - 3) (n - 2)                n - 2                 2 n
                                                                 2 gamma (-)
                                                                          2
                                           2      2 n - 1
                              2          mu  gamma (-----) n
                   2 n     (mu  + 1) n                2      2
          /(2 gamma (-)))/(----------- - -------------------)  - 3
                     2        n - 2                 2 n
                                             2 gamma (-)
                                                      2

     Categories: Package distrib

 -- Function: random_noncentral_student_t (N,NCP)
     random_noncentral_student_t (N,NCP,M)

     Returns a noncentral Student random variate nc_t(n, ncp) , with n>0. Calling random_noncentral_student_t with a third argument M, a random sample of size M will be simulated.

     The implemented algorithm is based on the fact that if X is a normal random variable Normal(ncp, 1) and S^2 is a chi square random variable with N degrees of freedom, Chi^2() , then

                                     X
                           U = -------------
                               /   2  \ 1/2
                               |  S   |
                               | ---  |
                               \  n   /

     is a noncentral Student random variable with n degrees of freedom and noncentrality parameter ncp, nc_t(n, ncp) .

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Chi-squared Random Variable
---------------------------

Let X_1, X_2, ..., X_k be independent and identically distributed Normal(0, 1) variables.  Then X^2 = sum(X_i^2, i, 1, n)

is said to follow a chi-square distribution with n degrees of freedom.

 -- Function: pdf_chi2 (X,N)
     Returns the value at X of the density function of a Chi-square random variable Chi^2() , with n>0. The Chi^2() random variable is equivalent to the Gamma(n/2,2) .

     The pdf is

                       [  n/2 - 1   - x/2
                       [ x        %e      unit_step(x)
                       [ -----------------------------     for x >= 0
                       [               n   n/2
             f(x, n) = [         gamma(-) 2
                       [               2
                       [
                       [ 0                                 otherwise

          (%i1) load ("distrib")$

          (%i2) pdf_chi2(x,n);
                             n/2 - 1   - x/2
                            x        %e      unit_step(x)
          (%o2)             -----------------------------
                                          n   n/2
                                    gamma(-) 2
                                          2

     Categories: Package distrib

 -- Function: cdf_chi2 (X,N)
     Returns the value at x of the distribution function of a Chi-square random variable Chi^2() , with n>0.

     The cdf is

                    [        n  x
                    [ (1 - Q(-, -))     for x >= 0
                    [        2  2
          F(x, n) = [
                    [ 0                 otherwise

     where Q(a,z) is the gamma_incomplete_regularized function.

          (%i1) load ("distrib")$

          (%i2) cdf_chi2(3,4);
                                                           3
          (%o2)        1 - gamma_incomplete_regularized(2, -)
                                                           2

          (%i3) float(%);
          (%o3)                  0.4421745996289252

     Categories: Package distrib

 -- Function: quantile_chi2 (Q,N)
     Returns the Q-quantile of a Chi-square random variable Chi^2() , with n>0; in other words, this is the inverse of cdf_chi2. Argument Q must be an element of [0,1].

     This function has no closed form and it is numerically computed.

          (%i1) load ("distrib")$

          (%i2) quantile_chi2(0.99,9);
          (%o2)                   21.66599433346194

     Categories: Package distrib

 -- Function: mean_chi2 (N)
     Returns the mean of a Chi-square random variable Chi^2() , with n>0.

     The Chi^2() random variable is equivalent to the Gamma(n/2,2) .

     The mean is

                                      E[X] = n

          (%i1) load ("distrib")$

          (%i2) mean_chi2(n);
          (%o2)                           n

     Categories: Package distrib

 -- Function: var_chi2 (N)
     Returns the variance of a Chi-square random variable Chi^2() , with n>0.

     The Chi^2() random variable is equivalent to the Gamma(n/2,2) .

     The variance is

                                     V[X] = 2 n

          (%i1) load ("distrib")$

          (%i2) var_chi2(n);
          (%o2)                          2 n

     Categories: Package distrib

 -- Function: std_chi2 (N)
     Returns the standard deviation of a Chi-square random variable Chi^2() , with n>0.

     The Chi^2() random variable is equivalent to the Gamma(n/2,2) .

     The standard deviation is

                               D[X] = sqrt(2) sqrt(n)

          (%i1) load ("distrib")$

          (%i2) std_chi2(n);
          (%o2)                    sqrt(2) sqrt(n)

     Categories: Package distrib

 -- Function: skewness_chi2 (N)
     Returns the skewness coefficient of a Chi-square random variable Chi^2() , with n>0.

     The Chi^2() random variable is equivalent to the Gamma(n/2,2) .

     The skewness coefficient is

                                             3/2
                                            2
                                   SK[X] = -------
                                           sqrt(n)

          (%i1) load ("distrib")$

          (%i2) skewness_chi2(n);
                                         3/2
                                        2
          (%o2)                        -------
                                       sqrt(n)

     Categories: Package distrib

 -- Function: kurtosis_chi2 (N)
     Returns the kurtosis coefficient of a Chi-square random variable Chi^2() , with n>0.

     The Chi^2() random variable is equivalent to the Gamma(n/2,2) .

     The kurtosis coefficient is

                                             12
                                     KU[X] = --
                                             n

          (%i1) load ("distrib")$

          (%i2) kurtosis_chi2(n);
                                         12
          (%o2)                          --
                                         n

     Categories: Package distrib

 -- Function: random_chi2 (N)
     random_chi2 (N,M)

     Returns a Chi-square random variate Chi^2() , with n>0. Calling random_chi2 with a second argument M, a random sample of size M will be simulated.

     The simulation is based on the Ahrens-Cheng algorithm. See random_gamma for details.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Noncentral Chi-squared Random Variable
--------------------------------------

Let X[1], X[2], ..., X[n] be n independent normally distributed random variables with means mu[k] and unit variances.  Then the random variable

sum(X[k]^2, k, 1, n)

has a noncentral chi-squared distribution.  The number of degrees of freedom is n, and the noncentrality parameter is defined by

sum(mu[k]^2, k, 1, n)

 -- Function: pdf_noncentral_chi2 (X,N,NCP)
     Returns the value at x of the density function of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0. To make use of this function, write first load("distrib").

     For x < 0, the pdf is 0, and for x >= 0 the pdf is

           f(x, n, ncp) =
                                                                 (- x) - ncp
                                                                 -----------
                            n                     x  n/4 - 1/2        2
                   bessel_i(- - 1, sqrt(ncp x)) (---)          %e            unit_step(x)
                            2                    ncp
                   ----------------------------------------------------------------------
                                                     2

     Categories: Package distrib

 -- Function: cdf_noncentral_chi2 (X,N,NCP)
     Returns the value at X of the distribution function of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: quantile_noncentral_chi2 (Q,N,NCP)
     Returns the Q-quantile of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0; in other words, this is the inverse of cdf_noncentral_chi2. Argument Q must be an element of [0,1].

     This function has no closed form and it is numerically computed.

     Categories: Package distrib

 -- Function: mean_noncentral_chi2 (N,NCP)
     Returns the mean of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0.

     The mean is

                                   E[X] = ncp + n

     Categories: Package distrib

 -- Function: var_noncentral_chi2 (N,NCP)
     Returns the variance of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0.

     The variance is

                                V[X] = 2 (2 ncp + n)

     Categories: Package distrib

 -- Function: std_noncentral_chi2 (N,NCP)
     Returns the standard deviation of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0.

     The standard deviation is

                           D[X] = sqrt(2) sqrt(2 ncp + n)

     Categories: Package distrib

 -- Function: skewness_noncentral_chi2 (N,NCP)
     Returns the skewness coefficient of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0.

     The skewness coefficient is

                    3/2
                   2    (n + 3 mu)
           SK[X] = ---------------
                              3/2
                    (n + 2 mu)

     Categories: Package distrib

 -- Function: kurtosis_noncentral_chi2 (N,NCP)
     Returns the kurtosis coefficient of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0.

     The kurtosis coefficient is

                     12 (n + 4 mu)
             KU[X] = -------------
                                2
                      (n + 2 mu)

     Categories: Package distrib

 -- Function: random_noncentral_chi2 (N,NCP)
     random_noncentral_chi2 (N,NCP,M)

     Returns a noncentral Chi-square random variate m4_noncentral_chi2(n,ncp), with n>0 and noncentrality parameter ncp>=0. Calling random_noncentral_chi2 with a third argument M, a random sample of size M will be simulated.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

F Random Variable
-----------------

Let S_1 and S_2 be independent random variables with a chi-squared distribution with degrees of freedom n and m, respectively.  Then F = (S_1/n)/(S_2/m) has an F distribution with n and m degrees of freedom.

 -- Function: pdf_f (X,M,N)
     Returns the value at X of the density function of a F random variable F(m,n), with m,n>0. To make use of this function, write first load("distrib").

     The pdf is

           f(x, m, n) =
                                                                   (- n) - m
                                                                   ---------
                              n n/2       n + m   n/2 - 1  n x         2
                             (-)    gamma(-----) x        (--- + 1)          unit_step(x)
                              m             2               m
                             ------------------------------------------------------------
                                                        m        n
                                                  gamma(-) gamma(-)
                                                        2        2

     Categories: Package distrib

 -- Function: cdf_f (X,M,N)
     Returns the value at X of the distribution function of a F random variable F(m,n), with m,n>0.

     The cdf is

                                                         n  m     n
           F(x, m, n) = (1 - beta_incomplete_regularized(-, -, -------))
                                                         2  2  m x + n
                                                                       unit_step(x)

          (%i1) load ("distrib")$

          (%i2) cdf_f(2,3,9/4);
                                                      9  3  3
          (%o2)       1 - beta_incomplete_regularized(-, -, --)
                                                      8  2  11

          (%i3) float(%);
          (%o3)                  0.6675672817900802

     Categories: Package distrib

 -- Function: quantile_f (Q,M,N)
     Returns the Q-quantile of a F random variable F(m,n), with m,n>0; in other words, this is the inverse of cdf_f. Argument Q must be an element of [0,1].

          (%i1) load ("distrib")$

          (%i2) quantile_f(2/5,sqrt(3),5);
          (%o2)                  0.5189478385736904

     Categories: Package distrib

 -- Function: mean_f (M,N)
     Returns the mean of a F random variable F(m,n), with m>0, n>2. To make use of this function, write first load("distrib").

     The mean is

                                             n
                                    E[X] = -----
                                           n - 2

     Categories: Package distrib

 -- Function: var_f (M,N)
     Returns the variance of a F random variable F(m,n), with m>0, n>4. To make use of this function, write first load("distrib").

     The variance is

                         2
                      2 n  (n + m - 2)
              V[X] = ------------------
                                      2
                     m (n - 4) (n - 2)

     Categories: Package distrib

 -- Function: std_f (M,N)
     Returns the standard deviation of a F random variable F(m,n), with m>0, n>4. To make use of this function, write first load("distrib").

     The standard deviation is

                                  n         n + m - 2
            D[X] = sqrt(2) sqrt(-----) sqrt(---------)
                                n - 2       m (n - 4)

     Categories: Package distrib

 -- Function: skewness_f (M,N)
     Returns the skewness coefficient of a F random variable F(m,n), with m>0, n>6. To make use of this function, write first load("distrib").

     The skewness coefficient is

                    3/2
                   2    sqrt(n - 4) (n + 2 m - 2)
           SK[X] = ------------------------------
                    (n - 6) sqrt(m (n + m - 2))

     Categories: Package distrib

 -- Function: kurtosis_f (M,N)
     Returns the kurtosis coefficient of a F random variable F(m,n), with m>0, n>8. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                                                  2
                    12 (m (n + m - 2) (5 n - 22) + (n - 4) (n - 2) )
            KU[X] = ------------------------------------------------
                             m (n - 8) (n - 6) (n + m - 2)

     Categories: Package distrib

 -- Function: random_f (M,N)
     random_f (M,N,K)

     Returns a F random variate F(m,n), with m,n>0. Calling random_f with a third argument K, a random sample of size K will be simulated.

     The simulation algorithm is based on the fact that if X is a Chi^2(m) random variable and Y is a Chi^2() random variable, then

                                  n X
                              F = ---
                                  m Y

     is a F random variable with M and N degrees of freedom, F(m,n).

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Exponential Random Variable
---------------------------

The exponential distribution is the probablity distribution of the time between events in a process where the events occur continuously and independently at a constant average rate.

 -- Function: pdf_exp (X,M)
     Returns the value at X of the density function of an Exponential(m) random variable, with m>0.

     The Exponential(m) random variable is equivalent to the Weibull(1,1/m) .

     The pdf is

                    [ m*exp(-m*x) for x >= 0
          f(x, m) = [
                    [ 0           otherwise

          (%i1) load ("distrib")$

          (%i2) pdf_exp(x,m);
                                   - m x
          (%o2)                m %e      unit_step(x)

     Categories: Package distrib

 -- Function: cdf_exp (X,M)
     Returns the value at X of the distribution function of an Exponential(m) random variable, with m>0.

     The Exponential(m) random variable is equivalent to the Weibull(1,1/m) .

     The cdf is

                   [ 1 - exp(-m*x)  for x >= 0
          F(x,n) = [
                   [ 0              otherwise

          (%i1) load ("distrib")$

          (%i2) cdf_exp(x,m);
                                    - m x
          (%o2)              (1 - %e     ) unit_step(x)

     Categories: Package distrib

 -- Function: quantile_exp (Q,M)
     Returns the Q-quantile of an Exponential(m) random variable, with m>0; in other words, this is the inverse of cdf_exp. Argument Q must be an element of [0,1].

     The Exponential(m) random variable is equivalent to the Weibull(1,1/m) .

          (%i1) load ("distrib")$

          (%i2) quantile_exp(0.56,5);
          (%o2)                  0.1641961104139661

          (%i3) quantile_exp(0.56,m);
                                 0.8209805520698303
          (%o3)                  ------------------
                                         m

     Categories: Package distrib

 -- Function: mean_exp (M)
     Returns the mean of an Exponential(m) random variable, with m>0.

     The Exponential(m) random variable is equivalent to the Weibull(1,1/m) .

     The mean is

                                             1
                                      E[X] = -
                                             m

          (%i1) load ("distrib")$

          (%i2) mean_exp(m);
                                          1
          (%o2)                           -
                                          m

     Categories: Package distrib

 -- Function: var_exp (M)
     Returns the variance of an Exponential(m) random variable, with m>0.

     The Exponential(m) random variable is equivalent to the Weibull(1,1/m) .

     The variance is

                                             1
                                        VX = --
                                              2
                                             m

          (%i1) load ("distrib")$

          (%i2) var_exp(m);
                                         1
          (%o2)                          --
                                          2
                                         m

     Categories: Package distrib

 -- Function: std_exp (M)
     Returns the standard deviation of an Exponential(m) random variable, with m>0.

     The Exponential(m) random variable is equivalent to the Weibull(1,1/m) .

     The standard deviation is

                                             1
                                      D[X] = -
                                             m

          (%i1) load ("distrib")$

          (%i2) std_exp(m);
                                          1
          (%o2)                           -
                                          m

     Categories: Package distrib

 -- Function: skewness_exp (M)
     Returns the skewness coefficient of an Exponential(m) random variable, with m>0.

     The Exponential(m) random variable is equivalent to the Weibull(1,1/m) .

     The skewness coefficient is

                                      SK[X] = 2

          (%i1) load ("distrib")$

          (%i2) skewness_exp(m);
          (%o2)                           2

     Categories: Package distrib

 -- Function: kurtosis_exp (M)
     Returns the kurtosis coefficient of an Exponential(m) random variable, with m>0.

     The Exponential(m) random variable is equivalent to the Weibull(1,1/m) .

     The kurtosis coefficient is

                                      KU[X] = 6

          (%i1) load ("distrib")$

          (%i2) kurtosis_exp(m);
          (%o2)                           6

     Categories: Package distrib

 -- Function: random_exp (M)
     random_exp (M,K)

     Returns an Exponential(m) random variate, with m>0. Calling random_exp with a second argument K, a random sample of size K will be simulated.

     The simulation algorithm is based on the general inverse method.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Lognormal Random Variable
-------------------------

The lognormal distribution is distribution for a random variable whose logarithm is normally distributed.

 -- Function: pdf_lognormal (X,M,S)
     Returns the value at X of the density function of a Lognormal(m,s) random variable, with s>0. To make use of this function, write first load("distrib").

     The pdf is

                             [                   2
                             [       (log(x) - m)
                             [     - -------------
                             [              2
                             [           2 s
                             [   %e
                f(x, m, s) = [ ---------------------      for x >= 0
                             [ sqrt(2) sqrt(%pi) s x
                             [
                             [ 0                          for x < 0

     Categories: Package distrib

 -- Function: cdf_lognormal (X,M,S)
     Returns the value at X of the distribution function of a Lognormal(m,s) random variable, with s>0. This function is defined in terms of Maxima's built-in error function erf.

     The cdf is

                                                   log(x) - m
                                               erf(----------)
                                                   sqrt(2) s     1
                    F(x, m, s) = unit_step(x) (--------------- + -)
                                                      2          2

          (%i1) load ("distrib")$

          (%i2) cdf_lognormal(x,m,s);
                                           log(x) - m
                                       erf(----------)
                                           sqrt(2) s     1
          (%o2)          unit_step(x) (--------------- + -)
                                              2          2

     See also erf

     Categories: Package distrib

 -- Function: quantile_lognormal (Q,M,S)
     Returns the Q-quantile of a Lognormal(m,s) random variable, with s>0; in other words, this is the inverse of cdf_lognormal. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

          (%i1) load ("distrib")$

          (%i2) quantile_lognormal(95/100,0,1);
                               sqrt(2) inverse_erf(9/10)
          (%o2)              %e

          (%i3) float(%);
          (%o3)                   5.180251602233015

     Categories: Package distrib

 -- Function: mean_lognormal (M,S)
     Returns the mean of a Lognormal(m,s) random variable, with s>0. To make use of this function, write first load("distrib").

     The mean is

                                             2
                                            s
                                            -- + m
                                            2
                                   E[X] = %e

     Categories: Package distrib

 -- Function: var_lognormal (M,S)
     Returns the variance of a Lognormal(m,s) random variable, with s>0. To make use of this function, write first load("distrib").

     The variance is

                                       2         2
                                      s         s  + 2 m
                            V[X] = (%e   - 1) %e

     Categories: Package distrib

 -- Function: std_lognormal (M,S)
     Returns the standard deviation of a Lognormal(m,s) random variable, with s>0. To make use of this function, write first load("distrib").

     The standard deviation is

                                                   2
                                                  s  + 2 m
                                         2        --------
                                        s            2
                          D[X] = sqrt(%e   - 1) %e

     Categories: Package distrib

 -- Function: skewness_lognormal (M,S)
     Returns the skewness coefficient of a Lognormal(m,s) random variable, with s>0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                          2          2
                                         s          s
                          SK[X] = sqrt(%e   - 1) (%e   + 2)

     Categories: Package distrib

 -- Function: kurtosis_lognormal (M,S)
     Returns the kurtosis coefficient of a Lognormal(m,s) random variable, with s>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                   2          2          2
                                4 s        3 s        2 s
                      KU[X] = %e     + 2 %e     + 3 %e     - 3

     Categories: Package distrib

 -- Function: random_lognormal (M,S)
     random_lognormal (M,S,N)

     Returns a Lognormal(m,s) random variate, with s>0. Calling random_lognormal with a third argument N, a random sample of size N will be simulated.

     Log-normal variates are simulated by means of random normal variates. See random_normal for details.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Gamma Random Variable
---------------------

The gamma distribution is a two-parameter family of probability distributions.  Maxima uses the parameterization using the shape and scale for the first and second parameters of the distribution.

 -- Function: pdf_gamma (X,A,B)
     Returns the value at X of the density function of a Gamma(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The shape parameter is a, and the scale parameter is b.

     The pdf is

                              a - 1   - x/b
                             x      %e      unit_step(x)
                f(x, a, b) = ---------------------------
                                               a
                                     gamma(a) b

     Categories: Package distrib

 -- Function: cdf_gamma (X,A,B)
     Returns the value at X of the distribution function of a Gamma(a,b) random variable, with a,b>0.

     The cdf is

                       [ 1 - Q(a,x/b) for x>= 0
          F(x, a, b) = [
                       [ 0            for x < 0

     where Q(a,z) is the gamma_incomplete_regularized function.

          (%i1) load ("distrib")$

          (%i2) cdf_gamma(3,5,21);
                                                           1
          (%o2)        1 - gamma_incomplete_regularized(5, -)
                                                           7

          (%i3) float(%);
          (%o3)                 4.402663157376807e-7

     Categories: Package distrib

 -- Function: quantile_gamma (Q,A,B)
     Returns the Q-quantile of a Gamma(a,b) random variable, with a,b>0; in other words, this is the inverse of cdf_gamma. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_gamma (A,B)
     Returns the mean of a Gamma(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The mean is

                                     E[X] = a b

     Categories: Package distrib

 -- Function: var_gamma (A,B)
     Returns the variance of a Gamma(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The variance is

                                               2
                                     V[X] = a b

     Categories: Package distrib

 -- Function: std_gamma (A,B)
     Returns the standard deviation of a Gamma(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The standard deviation is

                                 D[X] = sqrt(a) b

     Categories: Package distrib

 -- Function: skewness_gamma (A,B)
     Returns the skewness coefficient of a Gamma(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                               2
                                    SK[X] = -------
                                            sqrt(a)

     Categories: Package distrib

 -- Function: kurtosis_gamma (A,B)
     Returns the kurtosis coefficient of a Gamma(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                               6
                                       KU[X] = -
                                               a

     Categories: Package distrib

 -- Function: random_gamma (A,B)
     random_gamma (A,B,N)

     Returns a Gamma(a,b) random variate, with a,b>0. Calling random_gamma with a third argument N, a random sample of size N will be simulated.

     The implemented algorithm is a combination of two procedures, depending on the value of parameter A:

     For a>=1, Cheng, R.C.H. and Feast, G.M. (1979). SOME SIMPLE GAMMA VARIATE GENERATORS. Appl. Stat., 28, 3, 290-295.

     For 0<a<1, Ahrens, J.H. and Dieter, U. (1974). COMPUTER METHODS FOR SAMPLING FROM GAMMA, , POISSON AND BINOMIAL CDF_TRIBUTIONS. Computing, 12, 223-246.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Beta Random Variable
--------------------

The beta distribution is a family of distributions defined over [0,1] parameterized by two positive shape parameters a, and b.

 -- Function: pdf_beta (X,A,B)
     Returns the value at X of the density function of a Beta(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The pdf is

                        [        b - 1  a - 1
                        [ (1 - x)      x
           f(x, a, b) = [ -------------------   for 0 <= x <= 1
                        [     beta(a, b)
                        [
                        [ 0                     otherwise

     Categories: Package distrib

 -- Function: cdf_beta (X,A,B)
     Returns the value at X of the distribution function of a Beta(a,b) random variable, with a,b>0.

     The cdf is

                       [ 0                                     for x < 0
                       [
          F(x, a, b) = [ beta_incomplete_regularized(a, b, x)  for 0 <= x <= 1
                       [
                       [ 1                                     for x > 1

          (%i1) load ("distrib")$

          (%i2) cdf_beta(1/3,15,2);
                                         11
          (%o2)                       --------
                                      14348907

          (%i3) float(%);
          (%o3)                 7.666089131388195e-7

     Categories: Package distrib

 -- Function: quantile_beta (Q,A,B)
     Returns the Q-quantile of a Beta(a,b) random variable, with a,b>0; in other words, this is the inverse of cdf_beta. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_beta (A,B)
     Returns the mean of a Beta(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The mean is

                                              a
                                     E[X] = -----
                                            b + a

     Categories: Package distrib

 -- Function: var_beta (A,B)
     Returns the variance of a Beta(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The variance is

                             a b
              V[X] = --------------------
                            2
                     (b + a)  (b + a + 1)

     Categories: Package distrib

 -- Function: std_beta (A,B)
     Returns the standard deviation of a Beta(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The standard deviation is

                             a b
                     sqrt(---------)
                          b + a + 1
              D[X] = ---------------
                       abs(b + a)

     Categories: Package distrib

 -- Function: skewness_beta (A,B)
     Returns the skewness coefficient of a Beta(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                     2 (b - a) sqrt(b + a + 1)
             SK[X] = -------------------------
                       sqrt(a b) (b + a + 2)

     Categories: Package distrib

 -- Function: kurtosis_beta (A,B)
     Returns the kurtosis coefficient of a Beta(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                            2
                    3 (b + a + 1) (2 (b + a)  + a b (b + a - 6))
            KU[X] = -------------------------------------------- - 3
                            a b (b + a + 2) (b + a + 3)

     Categories: Package distrib

 -- Function: random_beta (A,B)
     random_beta (A,B,N)

     Returns a Beta(a,b) random variate, with a,b>0. Calling random_beta with a third argument N, a random sample of size N will be simulated.

     The implemented algorithm is defined in Cheng, R.C.H.  (1978). GENERATING BETA VARIATES WITH NONINTEGRAL SHAPE PARAMETERS. Communications of the ACM, 21:317-322

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Continuous Uniform Random Variable
----------------------------------

The continuous uniform distribution is constant over the interval [a,b] and is zero elsewhere.

 -- Function: pdf_continuous_uniform (X,A,B)
     Returns the value at X of the density function of a ContinuousUniform(a,b) random variable, with a<b. To make use of this function, write first load("distrib").

     The pdf

                       [ 1/(b-a) for 0 <= x <= 1
          f(x, a, b) = [
                       [ 0       otherwise

     and is 0 otherwise.

     Categories: Package distrib

 -- Function: cdf_continuous_uniform (X,A,B)
     Returns the value at X of the distribution function of a ContinuousUniform(a,b) random variable, with a<b. To make use of this function, write first load("distrib").

     The cdf is

                     [ 0              for x < a
          F(x,a,b) = [ (x-a)/(b-a)    for a <= x <= b
                     [ 1              for x > b

     Categories: Package distrib

 -- Function: quantile_continuous_uniform (Q,A,B)
     Returns the Q-quantile of a ContinuousUniform(a,b) random variable, with a<b; in other words, this is the inverse of cdf_continuous_uniform. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_continuous_uniform (A,B)
     Returns the mean of a ContinuousUniform(a,b) random variable, with a<b. To make use of this function, write first load("distrib").

     The mean is

                                            b + a
                                     E[X] = -----
                                              2

     Categories: Package distrib

 -- Function: var_continuous_uniform (A,B)
     Returns the variance of a ContinuousUniform(a,b) random variable, with a<b. To make use of this function, write first load("distrib").

     The variance is

                                                  2
                                           (b - a)
                                    V[X] = --------
                                              12

     Categories: Package distrib

 -- Function: std_continuous_uniform (A,B)
     Returns the standard deviation of a ContinuousUniform(a,b) random variable, with a<b. To make use of this function, write first load("distrib").

     The standard deviation is

                                          abs(b - a)
                                   D[X] = ----------
                                          2 sqrt(3)

     Categories: Package distrib

 -- Function: skewness_continuous_uniform (A,B)
     Returns the skewness coefficient of a ContinuousUniform(a,b) random variable, with a<b. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                      SK[X] = 0

     Categories: Package distrib

 -- Function: kurtosis_continuous_uniform (A,B)
     Returns the kurtosis coefficient of a ContinuousUniform(a,b) random variable, with a<b. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

     6 KU[X] = - - 5

     Categories: Package distrib

 -- Function: random_continuous_uniform (A,B)
     random_continuous_uniform (A,B,N)

     Returns a ContinuousUniform(a,b) random variate, with a<b. Calling random_continuous_uniform with a third argument N, a random sample of size N will be simulated.

     This is a direct application of the random built-in Maxima function.

     See also random To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Logistic Random Variable
------------------------

The logistic distribution is a continuous distribution where it's cumulative distribution function is the logistic function.

 -- Function: pdf_logistic (X,A,B)
     Returns the value at X of the density function of a <Logistice(a,b) random variable , with b>0. To make use of this function, write first load("distrib").

     a is the location parameter and b is the scale parameter.

     The pdf is

                                                a - x
                                                -----
                                                  b
                                              %e
                             f(x, a, b) = ----------------
                                               a - x
                                               -----
                                                 b       2
                                          b (%e      + 1)

     Categories: Package distrib

 -- Function: cdf_logistic (X,A,B)
     Returns the value at X of the distribution function of a <Logistice(a,b) random variable , with b>0. To make use of this function, write first load("distrib").

     The cdf is

                                                 1
                               F(x, a, b) = -----------
                                              a - x
                                              -----
                                                b
                                            %e      + 1

     Categories: Package distrib

 -- Function: quantile_logistic (Q,A,B)
     Returns the Q-quantile of a <Logistice(a,b) random variable , with b>0; in other words, this is the inverse of cdf_logistic. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_logistic (A,B)
     Returns the mean of a <Logistice(a,b) random variable , with b>0. To make use of this function, write first load("distrib").

     The mean is

                                      E[X] = a

     Categories: Package distrib

 -- Function: var_logistic (A,B)
     Returns the variance of a <Logistice(a,b) random variable , with b>0. To make use of this function, write first load("distrib").

     The variance is

                                             2  2
                                          %pi  b
                                   V[X] = -------
                                             3

     Categories: Package distrib

 -- Function: std_logistic (A,B)
     Returns the standard deviation of a <Logistice(a,b) random variable , with b>0. To make use of this function, write first load("distrib").

     The standard deviation is

                                         %pi abs(b)
                                  D[X] = ----------
                                          sqrt(3)

     Categories: Package distrib

 -- Function: skewness_logistic (A,B)
     Returns the skewness coefficient of a <Logistice(a,b) random variable , with b>0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                      SK[X] = 0

     Categories: Package distrib

 -- Function: kurtosis_logistic (A,B)
     Returns the kurtosis coefficient of a <Logistice(a,b) random variable , with b>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                              6
                                      KU[X] = -
                                              5

     Categories: Package distrib

 -- Function: random_logistic (A,B)
     random_logistic (A,B,N)

     Returns a <Logistice(a,b) random variate, with b>0. Calling random_logistic with a third argument N, a random sample of size N will be simulated.

     The implemented algorithm is based on the general inverse method.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Pareto Random Variable
----------------------

 -- Function: pdf_pareto (X,A,B)
     Returns the value at X of the density function of a Pareto(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The pdf is

                       [ a*b^a/x^(a+1)   for x >= b
          f(x, a, b) = [
                       [ 0               for x < b

     Categories: Package distrib

 -- Function: cdf_pareto (X,A,B)
     Returns the value at X of the distribution function of a Pareto(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The cdf is

                       [ 1 - (b/x)^a     for x >= 0
          F(x, a, b) = [
                       [ 0               for x < 0

     Categories: Package distrib

 -- Function: quantile_pareto (Q,A,B)
     Returns the Q-quantile of a Pareto(a,b) random variable, with a,b>0; in other words, this is the inverse of cdf_pareto. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_pareto (A,B)
     Returns the mean of a Pareto(a,b) random variable, with a>1,b>0. To make use of this function, write first load("distrib").

     The mean is E[X] = a*b/(a-1)

     Categories: Package distrib

 -- Function: var_pareto (A,B)
     Returns the variance of a Pareto(a,b) random variable, with a>2,b>0. To make use of this function, write first load("distrib").

     The variance is

                                        2
                                     a b
                        V[X] = ----------------
                                              2
                               (a - 2) (a - 1)

     Categories: Package distrib

 -- Function: std_pareto (A,B)
     Returns the standard deviation of a Pareto(a,b) random variable, with a>2,b>0. To make use of this function, write first load("distrib").

     The standard deviation is

                                        a
                                 sqrt(-----) b
                                      a - 2
                          D[X] = -------------
                                     a - 1

     Categories: Package distrib

 -- Function: skewness_pareto (A,B)
     Returns the skewness coefficient of a Pareto(a,b) random variable, with a>3,b>0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                               2 sqrt(a - 2) (a + 1)
                       SK[X] = ---------------------
                                  (a - 3) sqrt(a)

     Categories: Package distrib

 -- Function: kurtosis_pareto (A,B)
     Returns the kurtosis coefficient of a Pareto(a,b) random variable, with a>4,b>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                  3    2
                              6 (a  + a  - 6 a - 2)
                      KU[X] = --------------------- - 3
                                    2
                                a (a  - 7 a + 12)

     Categories: Package distrib

 -- Function: random_pareto (A,B)
     random_pareto (A,B,N)

     Returns a Pareto(a,b) random variate, with a>0,b>0. Calling random_pareto with a third argument N, a random sample of size N will be simulated.

     The implemented algorithm is based on the general inverse method.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Weibull Random Variable
-----------------------

 -- Function: pdf_weibull (X,A,B)
     Returns the value at X of the density function of a Weibull(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The pdf is

                       [                       a
                       [      x a - 1   - (x/b)
                       [   a (-)      %e         unit_step(x)
                       [      b
                       [   ----------------------------------   for x >= 0
                       [                   b
          f(x, a, b) = [
                       [ 0                                      for x < 0

     Categories: Package distrib

 -- Function: cdf_weibull (X,A,B)
     Returns the value at X of the distribution function of a Weibull(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The cdf is

                       [ 1 - exp(-(x/b)^a)      for x >= 0
          F(x, a, b) = [
                       [ 0                      for x < 0

     Categories: Package distrib

 -- Function: quantile_weibull (Q,A,B)
     Returns the Q-quantile of a Weibull(a,b) random variable, with a,b>0; in other words, this is the inverse of cdf_weibull. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_weibull (A,B)
     Returns the mean of a Weibull(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The mean is

                                             1
                                E[X] = gamma(- + 1) b
                                             a

     Categories: Package distrib

 -- Function: var_weibull (A,B)
     Returns the variance of a Weibull(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The variance is

                                   2             2 1        2
                     V[X] = (gamma(- + 1) - gamma (- + 1)) b
                                   a               a

     Categories: Package distrib

 -- Function: std_weibull (A,B)
     Returns the standard deviation of a Weibull(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The variance is

                                       2             2 1
                     D[X] = sqrt(gamma(- + 1) - gamma (- + 1)) b
                                       a               a

     Categories: Package distrib

 -- Function: skewness_weibull (A,B)
     Returns the skewness coefficient of a Weibull(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                        3                1            2               3 1
                  gamma(- + 1) - 3 gamma(- + 1) gamma(- + 1) + 2 gamma (- + 1)
                        a                a            a                 a
          SK[X] = ------------------------------------------------------------
                                      2             2 1      3/2
                               (gamma(- + 1) - gamma (- + 1))
                                      a               a

     Categories: Package distrib

 -- Function: kurtosis_weibull (A,B)
     Returns the kurtosis coefficient of a Weibull(a,b) random variable, with a,b>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                          4                1            3
           KU[X] = (gamma(- + 1) - 4 gamma(- + 1) gamma(- + 1)
                          a                a            a
                    2 1            2               4 1
           + 6 gamma (- + 1) gamma(- + 1) - 3 gamma (- + 1))
                      a            a                 a
                  2             2 1      2
          /(gamma(- + 1) - gamma (- + 1))  - 3
                  a               a

     Categories: Package distrib

 -- Function: random_weibull (A,B)
     random_weibull (A,B,N)

     Returns a Weibull(a,b) random variate, with a,b>0. Calling random_weibull with a third argument N, a random sample of size N will be simulated.

     The implemented algorithm is based on the general inverse method.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Rayleigh Random Variable
------------------------

The Rayleigh distribution coincides with the chi-squared distribution with two degrees of freedom.

 -- Function: pdf_rayleigh (X,B)
     Returns the value at X of the density function of a Rayleigh(b) random variable, with b>0.

     The Rayleigh(b) random variable is equivalent to the Weibull(2,1/b) .

     The pdf is

                    [ 2*b^2*x*exp(-b^2*x^2)    for x>= 0
          f(x, b) = [
                    [ 0                        otherwise

          (%i1) load ("distrib")$

          (%i2) pdf_rayleigh(x,b);
                                        2  2
                               2     - b  x
          (%o2)             2 b  x %e        unit_step(x)

     Categories: Package distrib

 -- Function: cdf_rayleigh (X,B)
     Returns the value at X of the distribution function of a Rayleigh(b) random variable, with b>0.

     The Rayleigh(b) random variable is equivalent to the Weibull(2,1/b) .

     The cdf is

                    [ 1 - exp(-b^2*x^2)    for x >= 0
          F(x, b) = [
                    [ 0                    for x < 0

          (%i1) load ("distrib")$

          (%i2) cdf_rayleigh(x,b);
                                      2  2
                                   - b  x
          (%o2)             (1 - %e       ) unit_step(x)

     Categories: Package distrib

 -- Function: quantile_rayleigh (Q,B)
     Returns the Q-quantile of a Rayleigh(b) random variable, with b>0; in other words, this is the inverse of cdf_rayleigh. Argument Q must be an element of [0,1].

     The Rayleigh(b) random variable is equivalent to the Weibull(2,1/b) .

          (%i1) load ("distrib")$

          (%i2) quantile_rayleigh(0.99,b);
                                  2.145966026289347
          (%o2)                   -----------------
                                          b

     Categories: Package distrib

 -- Function: mean_rayleigh (B)
     Returns the mean of a Rayleigh(b) random variable, with b>0.

     The Rayleigh(b) random variable is equivalent to the Weibull(2,1/b) .

     The mean is

                                         sqrt(%pi)
                                  E[X] = ---------
                                            2 b

          (%i1) load ("distrib")$

          (%i2) mean_rayleigh(b);
                                      sqrt(%pi)
          (%o2)                       ---------
                                         2 b

     Categories: Package distrib

 -- Function: var_rayleigh (B)
     Returns the variance of a Rayleigh(b) random variable, with b>0.

     The Rayleigh(b) random variable is equivalent to the Weibull(2,1/b) .

     The variance is

                                              %pi
                                          1 - ---
                                               4
                                   V[X] = -------
                                             2
                                            b

          (%i1) load ("distrib")$

          (%i2) var_rayleigh(b);
                                           %pi
                                       1 - ---
                                            4
          (%o2)                        -------
                                          2
                                         b

     Categories: Package distrib

 -- Function: std_rayleigh (B)
     Returns the standard deviation of a Rayleigh(b) random variable, with b>0.

     The Rayleigh(b) random variable is equivalent to the Weibull(2,1/b) .

     The standard deviation is

                                               %pi
                                      sqrt(1 - ---)
                                                4
                               D[X] = -------------
                                            b

          (%i1) load ("distrib")$

          (%i2) std_rayleigh(b);
                                             %pi
                                    sqrt(1 - ---)
                                              4
          (%o2)                     -------------
                                          b

     Categories: Package distrib

 -- Function: skewness_rayleigh (B)
     Returns the skewness coefficient of a Rayleigh(b) random variable, with b>0.

     The Rayleigh(b) random variable is equivalent to the Weibull(2,1/b) .

     The skewness coefficient is

                                      3/2
                                   %pi      3 sqrt(%pi)
                                   ------ - -----------
                                     4           4
                           SK[X] = --------------------
                                            %pi 3/2
                                       (1 - ---)
                                             4

          (%i1) load ("distrib")$

          (%i2) skewness_rayleigh(b);
                                   3/2
                                %pi      3 sqrt(%pi)
                                ------ - -----------
                                  4           4
          (%o2)                 --------------------
                                         %pi 3/2
                                    (1 - ---)
                                          4

     Categories: Package distrib

 -- Function: kurtosis_rayleigh (B)
     Returns the kurtosis coefficient of a Rayleigh(b) random variable, with b>0.

     The Rayleigh(b) random variable is equivalent to the Weibull(2,1/b) .

     The kurtosis coefficient is

                                               2
                                          3 %pi
                                      2 - ------
                                            16
                              KU[X] = ---------- - 3
                                           %pi 2
                                      (1 - ---)
                                            4

          (%i1) load ("distrib")$

          (%i2) kurtosis_rayleigh(b);
                                            2
                                       3 %pi
                                   2 - ------
                                         16
          (%o2)                    ---------- - 3
                                        %pi 2
                                   (1 - ---)
                                         4

     Categories: Package distrib

 -- Function: random_rayleigh (B)
     random_rayleigh (B,N)

     Returns a Rayleigh(b) random variate, with b>0. Calling random_rayleigh with a second argument N, a random sample of size N will be simulated.

     The implemented algorithm is based on the general inverse method.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Laplace Random Variable
-----------------------

The Laplace distribution is a continuous probability distribution that is sometimes called the double exponential distribution because it can be thought of as two exponential distributions spliced back to back.

 -- Function: pdf_laplace (X,A,B)
     Returns the value at X of the density function of a Laplace(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     Here, a is the location parameter (or mean), and b is the scale parameter, related to the variance.

     The pdf is

                                     abs(x - a)
                                   - ----------
                                         b
                                 %e
                    f(x, a, b) = --------------
                                      2 b

     1/(2*b)*exp(-abs(x-a)/b)

     Categories: Package distrib

 -- Function: cdf_laplace (X,A,B)
     Returns the value at X of the distribution function of a Laplace(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The cdf is

                       [ 1/2*exp((x-a)/b)     for x < a
          F(x, a, b) = [
                       [ 1-1/2*exp((x-a)/b)   for x >= a

     Categories: Package distrib

 -- Function: quantile_laplace (Q,A,B)
     Returns the Q-quantile of a Laplace(a,b) random variable, with b>0; in other words, this is the inverse of cdf_laplace. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_laplace (A,B)
     Returns the mean of a Laplace(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The mean is

                                      E[X] = a

     Categories: Package distrib

 -- Function: var_laplace (A,B)
     Returns the variance of a Laplace(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The variance is

                                               2
                                     V[X] = 2 b

     Categories: Package distrib

 -- Function: std_laplace (A,B)
     Returns the standard deviation of a Laplace(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The standard deviation is

                                  D[X] = sqrt(2) b

     Categories: Package distrib

 -- Function: skewness_laplace (A,B)
     Returns the skewness coefficient of a Laplace(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                      SK[X] = 0

     Categories: Package distrib

 -- Function: kurtosis_laplace (A,B)
     Returns the kurtosis coefficient of a Laplace(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                      KU[X] = 3

     Categories: Package distrib

 -- Function: random_laplace (A,B)
     random_laplace (A,B,N)

     Returns a Laplace(a,b) random variate, with b>0. Calling random_laplace with a third argument N, a random sample of size N will be simulated.

     The implemented algorithm is based on the general inverse method.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Cauchy Random Variable
----------------------

The Cauchy distribution (also known as the Lorentz distribution) is the distribution of of the ratio of two independent normally distributed random variables with mean zero.

Note that the mean, variance, standard deviation, skewness coefficient, and kurtosis coefficient are all undefined for the Cauchy distribution.  The integrals do not converge in this case.

 -- Function: pdf_cauchy (X,A,B)
     Returns the value at X of the density function of a Cauchy(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The pdf is

                                      b
                f(x, a, b) = -------------------
                                         2    2
                             %pi ((x - a)  + b )

     Categories: Package distrib

 -- Function: cdf_cauchy (X,A,B)
     Returns the value at X of the distribution function of a Cauchy(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The cdf is

                                               x - a
                                          atan(-----)
                                                 b      1
                             F(x, a, b) = ----------- + -
                                              %pi       2

     Categories: Package distrib

 -- Function: quantile_cauchy (Q,A,B)
     Returns the Q-quantile of a Cauchy(a,b) random variable, with b>0; in other words, this is the inverse of cdf_cauchy. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: random_cauchy (A,B)
     random_cauchy (A,B,N)

     Returns a Cauchy(a,b) random variate, with b>0. Calling random_cauchy with a third argument N, a random sample of size N will be simulated.

     The implemented algorithm is based on the general inverse method.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Gumbel Random Variable
----------------------

 -- Function: pdf_gumbel (X,A,B)
     Returns the value at X of the density function of a Gumbel(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The pdf is

                                       a - x
                                       -----
                             a - x       b
                             ----- - %e
                               b
                           %e
              f(x, a, b) = -----------------
                                   b

     Categories: Package distrib

 -- Function: cdf_gumbel (X,A,B)
     Returns the value at X of the distribution function of a Gumbel(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The cdf is

                                 a - x
                                 -----
                                   b
                             - %e
              F(x, a, b) = %e

     Categories: Package distrib

 -- Function: quantile_gumbel (Q,A,B)
     Returns the Q-quantile of a Gumbel(a,b) random variable, with b>0; in other words, this is the inverse of cdf_gumbel. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_gumbel (A,B)
     Returns the mean of a Gumbel(a,b) random variable, with b>0.

     The mean is

                                 E[X] = %gamma b + a

          (%i1) load ("distrib")$

          (%i2) mean_gumbel(a,b);
          (%o2)                     %gamma b + a

     where symbol %gamma stands for the Euler-Mascheroni constant. See also %gamma

     Categories: Package distrib

 -- Function: var_gumbel (A,B)
     Returns the variance of a Gumbel(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The variance is

                                             2  2
                                          %pi  b
                                   V[X] = -------
                                             6

     Categories: Package distrib

 -- Function: std_gumbel (A,B)
     Returns the standard deviation of a Gumbel(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The standard deviation is

                                           %pi b
                                   D[X] = -------
                                          sqrt(6)

     Categories: Package distrib

 -- Function: skewness_gumbel (A,B)
     Returns the skewness coefficient of a Gumbel(a,b) random variable, with b>0.

     The skewness coefficient is

                                          3/2
                                       2 6    zeta(3)
                               SK[X] = --------------
                                               3
                                            %pi

          (%i1) load ("distrib")$

          (%i2) skewness_gumbel(a,b);
                                      3/2
                                   2 6    zeta(3)
          (%o2)                    --------------
                                           3
                                        %pi

     where zeta stands for the Riemann's zeta function.

     Categories: Package distrib

 -- Function: kurtosis_gumbel (A,B)
     Returns the kurtosis coefficient of a Gumbel(a,b) random variable, with b>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                             12
                                     KU[X] = --
                                             5

     Categories: Package distrib Package distrib

 -- Function: random_gumbel (A,B)
     random_gumbel (A,B,N)

     Returns a Gumbel(a,b) random variate, with b>0. Calling random_gumbel with a third argument N, a random sample of size N will be simulated.

     The implemented algorithm is based on the general inverse method.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Functions and Variables for discrete distributions
==================================================

Maxima knows the following kinds of discrete distributions

General Finite Discrete Random Variable
---------------------------------------

 -- Function: pdf_general_finite_discrete (X,V)
     Returns the value at X of the probability function of a general finite discrete random variable, with vector probabilities v, such that Pr(X=i) = v_i. Vector v can be a list of nonnegative expressions, whose components will be normalized to get a vector of probabilities. To make use of this function, write first load("distrib").

          (%i1) load ("distrib")$

          (%i2) pdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
                                          4
          (%o2)                           -
                                          7

          (%i3) pdf_general_finite_discrete(2, [1, 4, 2]);
                                          4
          (%o3)                           -
                                          7

     Categories: Package distrib

 -- Function: cdf_general_finite_discrete (X,V)
     Returns the value at X of the distribution function of a general finite discrete random variable, with vector probabilities v.

     See pdf_general_finite_discrete for more details.

          (%i1) load ("distrib")$

          (%i2) cdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
                                          5
          (%o2)                           -
                                          7

          (%i3) cdf_general_finite_discrete(2, [1, 4, 2]);
                                          5
          (%o3)                           -
                                          7

          (%i4) cdf_general_finite_discrete(2+1/2, [1, 4, 2]);
                                          5
          (%o4)                           -
                                          7

     Categories: Package distrib

 -- Function: quantile_general_finite_discrete (Q,V)
     Returns the Q-quantile of a general finite discrete random variable, with vector probabilities v.

     See pdf_general_finite_discrete for more details.

     Categories: Package distrib

 -- Function: mean_general_finite_discrete (V)
     Returns the mean of a general finite discrete random variable, with vector probabilities v.

     See pdf_general_finite_discrete for more details.

     Categories: Package distrib

 -- Function: var_general_finite_discrete (V)
     Returns the variance of a general finite discrete random variable, with vector probabilities v.

     See pdf_general_finite_discrete for more details.

     Categories: Package distrib

 -- Function: std_general_finite_discrete (V)
     Returns the standard deviation of a general finite discrete random variable, with vector probabilities v.

     See pdf_general_finite_discrete for more details.

     Categories: Package distrib

 -- Function: skewness_general_finite_discrete (V)
     Returns the skewness coefficient of a general finite discrete random variable, with vector probabilities v.

     See pdf_general_finite_discrete for more details.

     Categories: Package distrib

 -- Function: kurtosis_general_finite_discrete (V)
     Returns the kurtosis coefficient of a general finite discrete random variable, with vector probabilities v.

     See pdf_general_finite_discrete for more details.

     Categories: Package distrib

 -- Function: random_general_finite_discrete (V)
     random_general_finite_discrete (V,M)

     Returns a general finite discrete random variate, with vector probabilities v. Calling random_general_finite_discrete with a second argument M, a random sample of size M will be simulated.

     See pdf_general_finite_discrete for more details.

          (%i1) load ("distrib")$

          (%i2) random_general_finite_discrete([1,3,1,5]);
          (%o2)                           4

          (%i3) random_general_finite_discrete([1,3,1,5], 10);
          (%o3)            [3, 4, 3, 4, 4, 4, 4, 2, 4, 4]

     Categories: Package distrib Random numbers

Binomial Random Variable
------------------------

The binomial distribution with parameters n and p is a discrete probability distribution.  It consists of n independent experiments where each experiment consists of a Boolean-valued outcome where a success occurs with a probablity p.

For example, a biased coin that comes up heads with probablity p is tossed n times.  Then the probability of exactly k heads in n tosses is given by the binomial distribution.

 -- Function: pdf_binomial (X,N,P)
     Returns the value at X of the probability function of a Binomial(n,p) random variable, with 0 \leq p \leq 1 and n a positive integer. To make use of this function, write first load("distrib").

     The pdf is

                                                         n - x  x
                      f(x, n, p) = binomial(n, x) (1 - p)      p

     Categories: Package distrib

 -- Function: cdf_binomial (X,N,P)
     Returns the value at X of the distribution function of a Binomial(n,p) random variable, with 0 \leq p \leq 1 and n a positive integer.

     The cdf is

          F(x, n, p) = beta_incomplete_regularized(n - floor(x), floor(x) + 1,
                                                                            1 - p)

          (%i1) load ("distrib")$

          (%i2) cdf_binomial(5,7,1/6);
                                        7775
          (%o2)                         ----
                                        7776

          (%i3) float(%);
          (%o3)                  0.9998713991769548

     Categories: Package distrib

 -- Function: quantile_binomial (Q,N,P)
     Returns the Q-quantile of a Binomial(n,p) random variable, with 0 \leq p \leq 1 and n a positive integer; in other words, this is the inverse of cdf_binomial. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_binomial (N,P)
     Returns the mean of a Binomial(n,p) random variable, with 0 \leq p \leq 1 and n a positive integer. To make use of this function, write first load("distrib").

     The mean is

                                      E[X] = n p

     Categories: Package distrib

 -- Function: var_binomial (N,P)
     Returns the variance of a Binomial(n,p) random variable, with 0 \leq p \leq 1 and n a positive integer. To make use of this function, write first load("distrib").

     The variance is

                                 V[X] = n (1 - p) p

     Categories: Package distrib

 -- Function: std_binomial (N,P)
     Returns the standard deviation of a Binomial(n,p) random variable, with 0 \leq p \leq 1 and n a positive integer. To make use of this function, write first load("distrib").

     The standard deviation is

                              D[X] = sqrt(n (1 - p) p)

     Categories: Package distrib

 -- Function: skewness_binomial (N,P)
     Returns the skewness coefficient of a Binomial(n,p) random variable, with 0 \leq p \leq 1 and n a positive integer. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                           1 - 2 p
                              SK[X] = -----------------
                                      sqrt(n (1 - p) p)

     Categories: Package distrib

 -- Function: kurtosis_binomial (N,P)
     Returns the kurtosis coefficient of a Binomial(n,p) random variable, with 0 \leq p \leq 1 and n a positive integer. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                       1 - 6 (1 - p) p
                               KU[X] = ---------------
                                         n (1 - p) p

     Categories: Package distrib

 -- Function: random_binomial (N,P)
     random_binomial (N,P,M)

     Returns a Binomial(n,p) random variate, with 0 \leq p \leq 1 and n a positive integer. Calling random_binomial with a third argument M, a random sample of size M will be simulated.

     The implemented algorithm is based on the one described in Kachitvichyanukul, V. and Schmeiser, B.W. (1988) BINOMIAL RANDOM VARIATE GENERATION. Communications of the ACM, 31, Feb., 216.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Poisson Random Variable
-----------------------

The Poisson distribution is a discrete probability distribution. It is the probability that a given number of events occur in a fixed interval when the events occur independently of the time of the last event, and the events occur with a known constant rate.

 -- Function: pdf_poisson (X,M)
     Returns the value at X of the probability function of a Poisson(m) random variable, with m>0. To make use of this function, write first load("distrib").

     The pdf is

                                             x   - m
                                            m  %e
                                  f(x, m) = --------
                                               x!

     Categories: Package distrib

 -- Function: cdf_poisson (X,M)
     Returns the value at X of the distribution function of a Poisson(m) random variable, with m>0.

     The cdf is

                F(x, m) = gamma_incomplete_regularized(floor(x) + 1, m)

          (%i1) load ("distrib")$

          (%i2) cdf_poisson(3,5);
          (%o2)          gamma_incomplete_regularized(4, 5)

          (%i3) float(%);
          (%o3)                  0.2650259152973619

     Categories: Package distrib

 -- Function: quantile_poisson (Q,M)
     Returns the Q-quantile of a Poisson(m) random variable, with m>0; in other words, this is the inverse of cdf_poisson. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_poisson (M)
     Returns the mean of a Poisson(m) random variable, with  m>0. To make use of this function, write first load("distrib").

     The mean is

                                      E[X] = m

     Categories: Package distrib

 -- Function: var_poisson (M)
     Returns the variance of a Poisson(m) random variable, with  m>0. To make use of this function, write first load("distrib").

     The variance is

                                      V[X] = m

     Categories: Package distrib

 -- Function: std_poisson (M)
     Returns the standard deviation of a Poisson(m) random variable, with m>0. To make use of this function, write first load("distrib").

     The standard deviation is

                                   D[X] = sqrt(m)

     Categories: Package distrib

 -- Function: skewness_poisson (M)
     Returns the skewness coefficient of a Poisson(m) random variable, with m>0. To make use of this function, write first load("distrib").

     The skewness is

                                              1
                                   SK[X] = -------
                                           sqrt(m)

     Categories: Package distrib

 -- Function: kurtosis_poisson (M)
     Returns the kurtosis coefficient of a Poisson random variable  Poi(m), with m>0. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                              1
                                      KU[X] = -
                                              m

     Categories: Package distrib

 -- Function: random_poisson (M)
     random_poisson (M,N)

     Returns a Poisson(m) random variate, with m>0. Calling random_poisson with a second argument N, a random sample of size N will be simulated.

     The implemented algorithm is the one described in Ahrens, J.H. and Dieter, U. (1982) COMPUTER GENERATION OF POISSON DEVIATES FROM MODIFIED NORMAL DISTRIBUTIONS. ACM Trans. Math. Software, 8, 2, June,163-179.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Bernoulli Random Variable
-------------------------

The Bernoulli distribution is a discrete probability distribution which takes on two values, 0 and 1.  The value 1 occurs with probability p, and 0 occurs with probabilty 1-p.

It is equivalent to the Binomial(1,p) distribution (see Binomial Random Variable)

 -- Function: pdf_bernoulli (X,P)
     Returns the value at X of the probability function of a Bernoulli(p) random variable, with 0 \leq p \leq 1.

     The Bernoulli(p) random variable is equivalent to the Binomial(1,p) .

     The mean is

                                                 1 - x  x
                                f(x, p) = (1 - p)      p

          (%i1) load ("distrib")$

          (%i2) pdf_bernoulli(1,p);
          (%o2)                           p

     Categories: Package distrib

 -- Function: cdf_bernoulli (X,P)
     Returns the value at X of the distribution function of a Bernoulli(p) random variable, with 0 \leq p \leq 1. To make use of this function, write first load("distrib").

     The cdf is

           F(x, n, p) = beta_incomplete_regularized(n - floor(x), floor(x) + 1,
                                                                              1 - p)

     Categories: Package distrib

 -- Function: quantile_bernoulli (Q,P)
     Returns the Q-quantile of a Bernoulli(p) random variable, with 0 \leq p \leq 1; in other words, this is the inverse of cdf_bernoulli. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_bernoulli (P)
     Returns the mean of a Bernoulli(p) random variable, with 0 \leq p \leq 1.

     The Bernoulli(p) random variable is equivalent to the Binomial(1,p) .

     The mean is

                                      E[X] = p

          (%i1) load ("distrib")$

          (%i2) mean_bernoulli(p);
          (%o2)                           p

     Categories: Package distrib

 -- Function: var_bernoulli (P)
     Returns the variance of a Bernoulli(p) random variable, with 0 \leq p \leq 1.

     The Bernoulli(p) random variable is equivalent to the Binomial(1,p) .

     The variance is

                                  V[X] = (1 - p) p

          (%i1) load ("distrib")$

          (%i2) var_bernoulli(p);
          (%o2)                       (1 - p) p

     Categories: Package distrib

 -- Function: std_bernoulli (P)
     Returns the standard deviation of a Bernoulli(p) random variable, with 0 \leq p \leq 1.

     The Bernoulli(p) random variable is equivalent to the Binomial(1,p) .

     The standard deviation is

                               D[X] = sqrt((1 - p) p)

          (%i1) load ("distrib")$

          (%i2) std_bernoulli(p);
          (%o2)                    sqrt((1 - p) p)

     Categories: Package distrib

 -- Function: skewness_bernoulli (P)
     Returns the skewness coefficient of a Bernoulli(p) random variable, with 0 \leq p \leq 1.

     The Bernoulli(p) random variable is equivalent to the Binomial(1,p) .

     The skewness coefficient is

                                           1 - 2 p
                               SK[X] = ---------------
                                       sqrt((1 - p) p)

          (%i1) load ("distrib")$

          (%i2) skewness_bernoulli(p);
                                       1 - 2 p
          (%o2)                    ---------------
                                   sqrt((1 - p) p)

     Categories: Package distrib

 -- Function: kurtosis_bernoulli (P)
     Returns the kurtosis coefficient of a Bernoulli(p) random variable, with 0 \leq p \leq 1.

     The Bernoulli(p) random variable is equivalent to the Binomial(1,p) .

     The kurtosis coefficient is

                                       1 - 6 (1 - p) p
                               KU[X] = ---------------
                                          (1 - p) p

          (%i1) load ("distrib")$

          (%i2) kurtosis_bernoulli(p);
                                   1 - 6 (1 - p) p
          (%o2)                    ---------------
                                      (1 - p) p

     Categories: Package distrib

 -- Function: random_bernoulli (P)
     random_bernoulli (P,N)

     Returns a Bernoulli(p) random variate, with 0 \leq p \leq 1. Calling random_bernoulli with a second argument N, a random sample of size N will be simulated.

     This is a direct application of the random built-in Maxima function.

     See also random To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Geometric Random Variable
-------------------------

The Geometric distibution is a discrete probability distribution.  It is the distribution of the number Bernoulli trials that fail before the first success.

Consider flipping a biased coin where heads occurs with probablity p.   Then the probability of k-1 tails in a row followed by heads is given by the Geometric(p) distribution.

 -- Function: pdf_geometric (X,P)
     Returns the value at X of the probability function of a Geometric(p) random variable, with 0 < p \leq 1

     The pdf is

                                                  x
                                 f(x, p) = (1 - p)  p

     This is interpreted as the probability of x failures before the first success.

     load("distrib") loads this function.

     Categories: Package distrib

 -- Function: cdf_geometric (X,P)
     Returns the value at X of the distribution function of a Geometric(p) random variable, with 0 < p \leq  1

     The cdf is

                                                floor(x) + 1
                           F(x, p) = 1 - (1 - p)

     load("distrib") loads this function.

     Categories: Package distrib

 -- Function: quantile_geometric (Q,P)
     Returns the Q-quantile of a Geometric(p) random variable, with 0 < p <= 1; in other words, this is the inverse of cdf_geometric. Argument Q must be an element of [0,1].

     The probability from which the quantile is derived is defined as p (1 - p)^x. This is interpreted as the probability of x failures before the first success.

     load("distrib") loads this function.

     Categories: Package distrib

 -- Function: mean_geometric (P)
     Returns the mean of a Geometric(p) random variable, with 0 < p \leq 1.

     The mean is

                                           1
                                    E[X] = - - 1
                                           p

     The probability from which the mean is derived is defined as p (1 - p)^x. This is interpreted as the probability of x failures before the first success.

     load("distrib") loads this function.

     Categories: Package distrib

 -- Function: var_geometric (P)
     Returns the variance of a Geometric(p) random variable, with 0 < p \leq 1.

     The variance is

                                           1 - p
                                    V[X] = -----
                                             2
                                            p

     load("distrib") loads this function.

     Categories: Package distrib

 -- Function: std_geometric (P)
     Returns the standard deviation of a Geometric(p) random variable, with 0 < p \leq 1.

                                        sqrt(1 - p)
                                 D[X] = -----------
                                             p

     load("distrib") loads this function.

     Categories: Package distrib

 -- Function: skewness_geometric (P)
     Returns the skewness coefficient of a Geometric(p) random variable, with 0 < p \leq 1.

     The skewness coefficient is

                                            2 - p
                                 SK[X] = -----------
                                         sqrt(1 - p)

     load("distrib") loads this function.

     Categories: Package distrib

 -- Function: kurtosis_geometric (P)
     Returns the kurtosis coefficient of a geometric random variable Geometric(p) , with 0 < p \leq 1.

     The kurtosis coefficient is

                                         2
                                        p  - 6 p + 6
                                KU[X] = ------------
                                           1 - p

     load("distrib") loads this function.

     Categories: Package distrib

 -- Function: random_geometric (P)
     random_geometric (P,N)

     random_geometric(P) returns one random sample from a Geometric(p) distribution, with 0 < p <= 1.

     random_geometric(P, N) returns a list of N random samples.

     The algorithm is based on simulation of Bernoulli trials.

     The probability from which the random sample is derived is defined as p (1 - p)^x. This is interpreted as the probability of x failures before the first success.

     load("distrib") loads this function.

     Categories: Package distrib Random numbers

Discrete Uniform Random Variable
--------------------------------

The Discrete uniform distribution is a discrete probablity distribution where a finite number of values are equally likely to occur.  The values are 1,2,3,...,n.

For example throwing a fair die of 6 sides numbered 1 through 6 follows a DiscreteUniform(1/6) distribution.

 -- Function: pdf_discrete_uniform (X,N)
     Returns the value at X of the probability function of a DiscreteUniform(n) random variable, with n a strictly positive integer. To make use of this function, write first load("distrib").

     The pdf is

                                                 1
                                       f(x, n) = -
                                                 n

     Categories: Package distrib

 -- Function: cdf_discrete_uniform (X,N)
     Returns the value at X of the distribution function of a DiscreteUniform(n) random variable, with n a strictly positive integer. To make use of this function, write first load("distrib").

     The cdf is

                                            floor(x)
                                  F(x, n) = --------
                                               n

     Categories: Package distrib

 -- Function: quantile_discrete_uniform (Q,N)
     Returns the Q-quantile of a DiscreteUniform(n) random variable, with n a strictly positive integer; in other words, this is the inverse of cdf_discrete_uniform. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_discrete_uniform (N)
     Returns the mean of a DiscreteUniform(n) random variable, with n a strictly positive integer. To make use of this function, write first load("distrib").

     The mean is

                                           n + 1
                                    E[X] = -----
                                             2

     Categories: Package distrib

 -- Function: var_discrete_uniform (N)
     Returns the variance of a DiscreteUniform(n) random variable, with n a strictly positive integer. To make use of this function, write first load("distrib").

     The variance is

                                            2
                                           n  - 1
                                    V[X] = ------
                                             12

     Categories: Package distrib

 -- Function: std_discrete_uniform (N)
     Returns the standard deviation of a DiscreteUniform(n) random variable, with n a strictly positive integer. To make use of this function, write first load("distrib").

     The standard deviation is

                                              2
                                        sqrt(n  - 1)
                                 D[X] = ------------
                                         2 sqrt(3)

     Categories: Package distrib

 -- Function: skewness_discrete_uniform (N)
     Returns the skewness coefficient of a DiscreteUniform(n) random variable, with n a strictly positive integer. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                      SK[X] = 0

     Categories: Package distrib

 -- Function: kurtosis_discrete_uniform (N)
     Returns the kurtosis coefficient of a DiscreteUniform(n) random variable, with n a strictly positive integer. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                              2
                                          6 (n  + 1)
                             KU[X] = - -----------------
                                       5 (n - 1) (n + 1)

     Categories: Package distrib

 -- Function: random_discrete_uniform (N)
     random_discrete_uniform (N,M)

     Returns a DiscreteUniform(n) random variate, with n a strictly positive integer. Calling random_discrete_uniform with a second argument M, a random sample of size M will be simulated.

     This is a direct application of the random built-in Maxima function.

     See also random To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Hypergeometric Random Variable
------------------------------

The hypergeometric distribution is a discrete probability distribution.

Let n_1 be the number of objects of a class A and n_2 be the number of objects of class B. We take out n objects, without replacment.  Then the hypergeometric distribution is the probability that exactly k objects are from class A.  Of course n \leq n_1 + n_2.

 -- Function: pdf_hypergeometric (X,N_1,N_2,N)
     Returns the value at X of the probability function of a Hypergeometric(n1,n2,n)

     random variable, with n_1, n_2 and n non negative integers and n\leq n_1+n_2. Being n_1 the number of objects of class A, n_2 the number of objects of class B, and n the size of the sample without replacement, this function returns the probability of event "exactly X objects are of class A".

     To make use of this function, write first load("distrib").

     The pdf is

                                     binomial(n_1, x) binomial(n_2, n - x)
                 f(x, n_1, n_2, n) = -----------------------------------
                                            binomial(n_2 + n_1, n)

     Categories: Package distrib

 -- Function: cdf_hypergeometric (X,N_1,N_2,N)
     Returns the value at X of the distribution function of a Hypergeometric(n1,n2,n)

     random variable, with n_1, n_2 and n non negative integers and n\leq n_1+n_2. See pdf_hypergeometric for a more complete description.

     To make use of this function, write first load("distrib").

     The cdf is

                                floor(x)
                                ====
                                \
                                 >       binomial(n_1, k) binomial(n_2, n - k)
                                /
                                ====
                                k = 0
            F(x, n_1, n_2, n) = --------------------------------------------
                                            binomial(n_2 + n_1, n)

     Categories: Package distrib

 -- Function: quantile_hypergeometric (Q,N1,N2,N)
     Returns the Q-quantile of a Hypergeometric(n1,n2,n) random variable, with N1, N2 and N non negative integers and n\leq n1+n2; in other words, this is the inverse of cdf_hypergeometric. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_hypergeometric (N_1,N_2,N)
     Returns the mean of a discrete uniform random variable Hypergeometric(n_1,n_2,n) , with n_1, n_2 and n non negative integers and n\leq n_1+n_2. To make use of this function, write first load("distrib").

     The mean is

                                           n n_1
                                   E[X] = -------
                                          n_2 + n_1

     Categories: Package distrib

 -- Function: var_hypergeometric (N1,N2,N)
     Returns the variance of a hypergeometric  random variable Hypergeometric(n_1,n_2,n) , with n1, n2 and n non negative integers and n<=n1+n2. To make use of this function, write first load("distrib").

     The variance is

                                  n n_1 n_2 (n_2 + n_1 - n)
                          V[X] = ----------------------------
                                                            2
                                 (n_2 + n_1 - 1) (n_2 + n_1)

     Categories: Package distrib

 -- Function: std_hypergeometric (N_1,N_2,N)
     Returns the standard deviation of a Hypergeometric(n_1,n_2,n) random variable, with n_1, n_2 and n non negative integers and n\leq n_1+n_2. To make use of this function, write first load("distrib").

     The standard deviation is

                                    n n_1 n_2 (n_2 + n_1 - n)
                               sqrt(-------------------------)
                                          n_2 + n_1 - 1
                        D[X] = -------------------------------
                                          n_2 + n_1

     Categories: Package distrib

 -- Function: skewness_hypergeometric (N_1,N_2,N)
     Returns the skewness coefficient of a Hypergeometric(n1,n2,n) random variable, with n_1, n_2 and n non negative integers and n\leq n1+n2. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                                           n_2 + n_1 - 1
                  (n_2 - n_1) (n_2 + n_1 - 2 n) sqrt(-------------------------)
                                                     n n_1 n_2 (n_2 + n_1 - n)
          SK[X] = -------------------------------------------------------------
                                          n_2 + n_1 - 2

     Categories: Package distrib

 -- Function: kurtosis_hypergeometric (N_1,N_2,N)
     Returns the kurtosis coefficient of a Hypergeometric(n_1,n_2,n) random variable, with n_1, n_2 and n non negative integers and n\leq n1+n2. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                              2
          KU[X] = ((n_2 + n_1 - 1) (n_2 + n_1)
                                          2                          2
            3 n_1 n_2 ((n - 2) (n_2 + n_1)  + 6 n (n_2 + n_1 - n) - n  (n_2 + n_1))
           (-----------------------------------------------------------------------
                                                    2
                                         (n_2 + n_1)
           - 6 n (n_2 + n_1 - n) + (n_2 + n_1) (n_2 + n_1 + 1)))
          /(n n_1 n_2 (n_2 + n_1 - 3) (n_2 + n_1 - 2) (n_2 + n_1 - n)) - 3

     Categories: Package distrib

 -- Function: random_hypergeometric (N1,N2,N)
     random_hypergeometric (N1,N2,N,M)

     Returns a Hypergeometric(n1,n2,n) random variate, with N1, N2 and N non negative integers and n<=n1+n2. Calling random_hypergeometric with a fourth argument M, a random sample of size M will be simulated.

     Algorithm described in Kachitvichyanukul, V., Schmeiser, B.W. (1985) COMPUTER GENERATION OF HYPERGEOMETRIC RANDOM VARIATES. Journal of Statistical Computation and Simulation 22, 127-145.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers

Negative Binomial Random Variable
---------------------------------

The negative binomial distribution is a discrete probability distribution.  Suppose we have a sequence of Bernoulli trials where each trial has two outcomes called ``success'' and ``failure'' where ``success'' occurs with probablity p and ``failure'' with probability 1-p.  We observe the sequence until a predefined number r of sucesses have occurred.  Then the number of failures seen will have a NegativeBinomial(r,p) distribution.

 -- Function: pdf_negative_binomial (X,N,P)
     Returns the value at X of the probability function of a NegativeBinomial(n,p) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

     The pdf is

                                             x  n
                                      (1 - p)  p  gamma(x + n)
                         f(x, n, p) = ------------------------
                                            gamma(n) x!

     Categories: Package distrib

 -- Function: cdf_negative_binomial (X,N,P)
     Returns the value at X of the distribution function of a NegativeBinomial(n,p) random variable, with 0 < p \leq 1 and n a positive number.

     The cdf is

             F(x, n, p) = beta_incomplete_regularized(n, floor(x) + 1, p)

          (%i1) load ("distrib")$

          (%i2) cdf_negative_binomial(3,4,1/8);
                                        3271
          (%o2)                        ------
                                       524288

     Categories: Package distrib

 -- Function: quantile_negative_binomial (Q,N,P)
     Returns the Q-quantile of a NegativeBinomial(n,p) random variable, with 0 < p \leq 1 and n a positive number; in other words, this is the inverse of cdf_negative_binomial. Argument Q must be an element of [0,1]. To make use of this function, write first load("distrib").

     Categories: Package distrib

 -- Function: mean_negative_binomial (N,P)
     Returns the mean of a NegativeBinomial(n,p) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

     The mean is

                                         n (1 - p)
                                  E[X] = ---------
                                             p

     Categories: Package distrib

 -- Function: var_negative_binomial (N,P)
     Returns the variance of a NegativeBinomial(n,p) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

     The variance is

                                         n (1 - p)
                                  V[X] = ---------
                                             2
                                            p

     Categories: Package distrib

 -- Function: std_negative_binomial (N,P)
     Returns the standard deviation of a NegativeBinomial(n,p) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

     The standard deviation is

                                      sqrt(n (1 - p))
                               D[X] = ---------------
                                             p

     Categories: Package distrib

 -- Function: skewness_negative_binomial (N,P)
     Returns the skewness coefficient of a NegativeBinomial(n,p) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

     The skewness coefficient is

                                            2 - p
                               SK[X] = ---------------
                                       sqrt(n (1 - p))

     Categories: Package distrib

 -- Function: kurtosis_negative_binomial (N,P)
     Returns the kurtosis coefficient of a NegativeBinomial(n,p) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

     The kurtosis coefficient is

                                         2
                                        p  - 6 p + 6
                                KU[X] = ------------
                                         n (1 - p)

     Categories: Package distrib

 -- Function: random_negative_binomial (N,P)
     random_negative_binomial (N,P,M)

     Returns a NegativeBinomial(n,p) random variate, with 0 < p \leq 1 and n a positive number. Calling random_negative_binomial with a third argument M, a random sample of size M will be simulated.

     Algorithm described in Devroye, L. (1986) NON-UNIFORM RANDOM VARIATE GENERATION. Springer Verlag, p. 480.

     To make use of this function, write first load("distrib").

     Categories: Package distrib Random numbers