Package distrib (Maxima 5.49.0 Manual)

## 54 Package distrib ¶

### 54.1 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 cumulative distribution function is defined as $$ F\left(x\right)=\int_{ -\infty }^{x}{f\left(u\right)\;du} $$

which equals the probability \({\rm Pr}(X \le x).\)

The mean value is a localization parameter and is defined as $$ E\left[X\right]=\int_{ -\infty }^{\infty }{x\,f\left(x\right)\;dx} $$

The variance is a measure of variation, $$ V\left[X\right]=\int_{ -\infty }^{\infty }{f\left(x\right)\,\left(x -E\left[X\right]\right)^2\;dx} $$

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, $$ SK\left[X\right]={{\int_{ -\infty }^{\infty }{f\left(x\right)\, \left(x-E\left[X\right]\right)^3\;dx}}\over{D\left[X\right]^3}} $$

And the kurtosis coefficient measures the peakedness of the distribution, $$ KU\left[X\right]={{\int_{ -\infty }^{\infty }{f\left(x\right)\, \left(x-E\left[X\right]\right)^4\;dx}}\over{D\left[X\right]^4}}-3 $$

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 cumulative distribution function is $$ F\left(x\right)=\sum_{x_{i}\leq x}{f\left(x_{i}\right)} $$

The mean, variance, standard deviation, skewness coefficient and kurtosis coefficient take the form $$ \eqalign{ E\left[X\right]&=\sum_{x_{i}}{x_{i}f\left(x_{i}\right)}, \cr V\left[X\right]&=\sum_{x_{i}}{f\left(x_{i}\right)\left(x_{i}-E\left[X\right]\right)^2},\cr D\left[X\right]&=\sqrt{V\left[X\right]},\cr SK\left[X\right]&={{\sum_{x_{i}}{f\left(x\right)\, \left(x-E\left[X\right]\right)^3\;dx}}\over{D\left[X\right]^3}}, \cr KU\left[X\right]&={{\sum_{x_{i}}{f\left(x\right)\, \left(x-E\left[X\right]\right)^4\;dx}}\over{D\left[X\right]^4}}-3, } $$

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 ·

### 54.2 Functions and Variables for continuous distributions ¶

Maxima knows the following kinds of continuous distributions.

#### 54.2.1 Normal Random Variable ¶

Normal random variables (also called Gaussian) is denoted by \({\it 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 \({\it Normal}(m, s)\) random variable, with \(s>0\). To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x; m, s) = {1\over s\sqrt{2\pi}} e^{\displaystyle -{(x-m)^2\over 2s^2}} $$

  Categories: Package distrib ·

Function: cdf_normal (x,m,s) ¶

  Returns the value at x of the cumulative distribution function of a \({\it 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: $$ F(x; m, s) = {1\over 2} + {1\over 2} {\rm erf}\left(x-m\over s\sqrt{2}\right) $$

      (%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 \({\it 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.6448536269514724

  Categories: Package distrib ·

Function: mean_normal (m,s) ¶

  Returns the mean of a \({\it 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 \({\it Normal}(m, s)\) random variable, with \(s>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = s^2 $$

  Categories: Package distrib ·

Function: std_normal (m,s) ¶

  Returns the standard deviation of a \({\it 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 \({\it 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 \({\it 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 $$ KU[X] = 0 $$

  Categories: Package distrib ·

Function: random_normal (m,s)
random_normal (m,s,n) ¶

  Returns a \({\it 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 ·

#### 54.2.2 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 \({\it Normal}(0, 1)\) variable and \(V\) is an independent \(\chi^2\) random variable with \(n\) degrees of freedom, then

$$ Z \over \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 $$ f(x; n) = \left[\sqrt{n} B\left({1\over 2}, {n\over 2}\right)\right]^{-1} \left(1+{x^2\over n}\right)^{\displaystyle -{n+1\over 2}} $$

  Categories: Package distrib ·

Function: cdf_student_t (x,n) ¶

  Returns the value at x of the cumulative distribution function of a Student random variable \(t(n)\) , with \(n>0\) degrees of freedom.

  The cdf is $$ F(x; n) = \cases{ 1-\displaystyle{1\over 2} I_t\left({n\over 2}, {1\over 2}\right) & $x \ge 0$ \cr \cr \displaystyle{1\over 2} I_t\left({n\over 2}, {1\over 2}\right) & $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 $$ V[X] = {n\over 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 $$ D[X] = \sqrt{\displaystyle{n\over 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 $$ KU[X] = {6\over 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 \({\it Normal}(0, 1)\) and \(S^2\) is a \(\chi^2\) random variable with \(n\) degrees of freedom, \(\chi^2(n)\) , then

  $$ X={{Z}\over{\sqrt{{S^2}\over{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 ·

#### 54.2.3 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 \({\it Normal}(n, ncp)\) and \(S^2\) be an independent \(\chi^2\) random variable with \(n\) degrees of freedom, the random variable $$ U = {X \over \sqrt{S^2\over 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 \({\it 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 $$ f(x; n, \mu) = \left[\sqrt{n} B\left({1\over 2}, {n\over 2}\right)\right]^{-1}\left(1+{x^2\over n}\right)^{-{(n+1)/2}} e^{-\mu^2/ 2} \bigg[A_n(x; \mu) + B_n(x; \mu)\bigg] $$

  where $$ \eqalign{ A_n(x;\mu) &= {}_1F_1\left({n+1\over 2}; {1\over 2}; {\mu^2 x^2\over 2\left(x^2+n\right)}\right) \cr B_n(x;\mu) &= {\sqrt{2}\mu x \over \sqrt{x^2+n}} {\Gamma\left({n\over 2} + 1\right)\over \Gamma\left({n+1\over 2}\right)}\; {}_1F_1\left({n\over 2} + 1; {3\over 2}; {\mu^2 x^2\over 2\left(x^2+n\right)}\right) } $$

  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.018898223650461364 by 15934951/843198350 = 0.018898223650461364

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

      rat: replaced 4.136255165816327 by 51033443/12338079 = 4.136255165816332

      rat: replaced 1.0806143216420299 by 49366521/45683756 = 1.0806143216420296

      rat: replaced 0.0565127306411839 by 5608717/99246965 = 0.05651273064118384

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

      rat: replaced 160.62691761849732 by 178374907/1110492 = 160.62691761849703
                                  7/2                          7/2
            0.042964144174009046 5      1.3236503072892878e-6 5
      (%o2) ------------------------- + --------------------------
               3/2   5/2                        sqrt(%pi)
              2    14    sqrt(%pi)
                                                                    7/2
                                               1.94793720435093e-4 5
                                             + ------------------------
                                                         %pi

      (%i3) float(%);
      (%o3)                 0.020805931594056706

  Categories: Package distrib ·

Function: cdf_noncentral_student_t (x,n,ncp) ¶

  Returns the value at x of the cumulative distribution function of a noncentral Student random variable \({\it 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 \({\it 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 \({\it 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 $$ E[X] = {\mu \sqrt{n}\; \Gamma\left(\displaystyle{n-1\over 2}\right) \over \sqrt{2}\;\Gamma\left(\displaystyle{n\over 2}\right)} $$

  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 \({\it 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 $$ V[X] = {n(\mu^2+1)\over n-2} - {n\mu^2\; \Gamma\left(\displaystyle{n-1\over 2}\right)^2 \over 2\Gamma\left(\displaystyle{n\over 2}\right)^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 \({\it 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 $$ D[X] = \sqrt{{n(\mu^2+1)\over n-2} - {n\mu^2\; \Gamma\left(\displaystyle{n-1\over 2}\right)^2 \over 2\Gamma\left(\displaystyle{n\over 2}\right)^2}} $$

  Categories: Package distrib ·

Function: skewness_noncentral_student_t (n,ncp) ¶

  Returns the skewness coefficient of a noncentral Student random variable \({\it 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 $$ \eqalign{ SK[U] &= {\mu\sqrt{n}\,\Gamma\left({{n-1}\over{2}}\right) \over{\sqrt{2}\Gamma\left({{n }\over{2}}\right)\sigma^{3}}}\left({{n \left(2n+\mu^2-3\right)}\over{\left(n-3\right)\left(n-2\right)}} -2\sigma^2\right) \cr \sigma^2 &= {{n\left(\mu^2+1\right)}\over{n-2}}-{{n \mu^2\, \Gamma\left({{n-1}\over{2}}\right)^2}\over{2\Gamma\left({{n }\over{2}}\right)^2}} } $$

  Categories: Package distrib ·

Function: kurtosis_noncentral_student_t (n,ncp) ¶

  Returns the kurtosis coefficient of a noncentral Student random variable \({\it 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

  $$ \eqalign{ KU[U] &= {\mu_4\over \sigma^4} - 3\cr \mu_4 &= {{\left(\mu^4+6\mu^2+3\right)n^2}\over{(n-4)(n-2)}} -\left({{n\left(3(3n-5)+\mu^2(n+1)\right) }\over{(n-3)(n-2)}}-3\sigma^2\right) F \cr \sigma^2 &= {{n\left(\mu^2+1\right)}\over{n-2}}-{{n \mu^2 \Gamma\left({{n-1}\over{2}}\right)^2}\over{2\Gamma\left({{n }\over{2}}\right)^2}} \cr F &= {n\mu^2\Gamma\left({n-1\over 2}\right)^2 \over 2\sigma^4\Gamma\left({n\over 2}\right)^2} } $$
  Categories: Package distrib ·

Function: random_noncentral_student_t (n,ncp)
random_noncentral_student_t (n,ncp,m) ¶

  Returns a noncentral Student random variate \({\it 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 \({\it Normal}(ncp, 1)\) and \(S^2\) is a \(\chi^2\) random variable with n degrees of freedom, \(\chi^2(n)\) , then $$ U={{X}\over{\sqrt{{S^2}\over{n}}}} $$

  is a noncentral Student random variable with \(n\) degrees of freedom and noncentrality parameter \(ncp\), \({\it nc\_t}(n, ncp)\) .

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

  Categories: Package distrib · Random numbers ·

#### 54.2.4 Chi-squared Random Variable ¶

Let \(X_1, X_2, \ldots, X_n\) be independent and identically distributed \({\it Normal}(0, 1)\) variables. Then $$ X^2 = \sum_{i=1}^n X_i^2 $$

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(n)\) , with \(n>0\). The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .

  The pdf is

  $$ f(x; n) = \cases{ \displaystyle{x^{n/2-1} e^{-x/2} \over 2^{n/2} \Gamma\left(\displaystyle{n\over 2}\right)} & for $x > 0$ \cr \cr 0 & otherwise } $$

      (%i1) load ("distrib")$

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

  Categories: Package distrib ·

Function: cdf_chi2 (x,n) ¶

  Returns the value at \(x\) of the cumulative distribution function of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\).

  The cdf is $$ F(x; n) = \cases{ 1 - Q\left(\displaystyle{n\over 2}, {x\over 2}\right) & $x > 0$ \cr 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.44217459962892525

  Categories: Package distrib ·

Function: quantile_chi2 (q,n) ¶

  Returns the q-quantile of a Chi-square random variable \(\chi^2(n)\) , 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(n)\) , with \(n>0\).

  The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .

  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(n)\) , with \(n>0\).

  The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .

  The variance is $$ V[X] = 2n $$

      (%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(n)\) , with \(n>0\).

  The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .

  The standard deviation is $$ D[X] = \sqrt{2n} $$

      (%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(n)\) , with \(n>0\).

  The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .

  The skewness coefficient is $$ SK[X] = \sqrt{8\over 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(n)\) , with \(n>0\).

  The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .

  The kurtosis coefficient is $$ KU[X] = {12\over 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(n)\) , 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 ·

#### 54.2.5 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_{k=1}^n X_k^2 $$

has a noncentral \(\chi^2\) distribution. The number of degrees of freedom is \(n\), and the noncentrality parameter is defined by

$$ \sum_{k=1}^n \mu_k^2 $$

Function: pdf_noncentral_chi2 (x,n,ncp) ¶

  Returns the value at \(x\) of the density function of a noncentral \(\chi^2\) random variable m4_noncentral_chi2(n,ncp) , with \(n>0\) and noncentrality parameter \(ncp \ge 0.\) To make use of this function, write first `load("distrib")`.

  For \(x < 0\), the pdf is 0, and for \(x \ge 0\) the pdf is $$ f(x; n, \lambda) = {1\over 2}e^{-(x+\lambda)/2} \left(x\over \lambda\right)^{n/4-1/2}I_{{n\over 2} - 1}\left(\sqrt{n \lambda}\right) $$

  Categories: Package distrib ·

Function: cdf_noncentral_chi2 (x,n,ncp) ¶

  Returns the value at x of the cumulative distribution function of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp) , with \(n>0\) and noncentrality parameter \(ncp \ge 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 \ge 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 \ge 0.\)

  The mean is $$ E[X] = n + \mu $$

  where \(\mu\) is the noncentrality parameter ncp.

  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 \ge 0.\)

  The variance is $$ V[X] = 2(n+2\mu) $$

  where \(\mu\) is the noncentrality parameter ncp.

  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 \ge 0.\)

  The standard deviation is $$ D[X] = \sqrt{2(n+2\mu)} $$

  where \(\mu\) is the noncentrality parameter ncp.

  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 \ge 0.\)

  The skewness coefficient is $$ SK[X] = {2^{3/2}(n+3\mu) \over (n+2\mu)^{3/2}} $$

  where \(\mu\) is the noncentrality parameter ncp.

  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 \ge 0.\)

  The kurtosis coefficient is $$ KU[X] = {12(n+4\mu)\over (2+2\mu)^2} $$

  where \(\mu\) is the noncentrality parameter ncp.

  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 \ge 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 ·

#### 54.2.6 F Random Variable ¶

Let \(S_1\) and \(S_2\) be independent random variables with a \(\chi^2\) distribution with degrees of freedom \(n\) and \(m\), respectively. Then $$ F = {S_1/n \over 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) = \cases{ B\left(\displaystyle{m\over 2}, \displaystyle{n\over 2}\right)^{-1} \left(\displaystyle{m\over n}\right)^{m/ 2} x^{m/2-1} \left(1 + \displaystyle{m\over n}x\right)^{-\left(n+m\right)/2} & $x > 0$ \cr \cr 0 & otherwise } $$

  Categories: Package distrib ·

Function: cdf_f (x,m,n) ¶

  Returns the value at x of the cumulative distribution function of a F random variable \(F(m,n)\), with \(m,n>0\).

  The cdf is $$ F(x; m, n) = \cases{ 1 - I_z\left(\displaystyle{m\over 2}, {n\over 2}\right) & $x > 0$ \cr 0 & otherwise } $$

  where $$ z = {n\over mx+n} $$

  and \(I_z(a,b)\) is the beta_incomplete_regularized function.

      (%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 $$ E[X] = {n\over 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 $$ V[X] = {2n^2(n+m-2) \over m(n-4)(n-2)^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 $$ D[X] = {\sqrt{2}\, n \over n-2} \sqrt{n+m-2\over 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 $$ SK[X] = {(n+2m-2)\sqrt{8(n-4)} \over (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 $$ KU[X] = 12{m(n+m-2)(5n-22) + (n-4)(n-2)^2 \over 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(n)\) random variable, then $$ F={{n X}\over{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 ·

#### 54.2.7 Exponential Random Variable ¶

The exponential distribution is the probability 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 \({\it Exponential}(m)\) random variable, with \(m>0\).

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

  The pdf is $$ f(x; m) = \cases{ me^{-mx} & for $x \ge 0$ \cr 0 & otherwise } $$

      (%i1) load ("distrib")$

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

  Categories: Package distrib ·

Function: cdf_exp (x,m) ¶

  Returns the value at x of the cumulative distribution function of an \({\it Exponential}(m)\) random variable, with \(m>0\).

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

  The cdf is $$ F(x; m) = \cases{ 1 - e^{-mx} & $x \ge 0$ \cr 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 \({\it 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 \({\it Exponential}(m)\) random variable is equivalent to the \({\it 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 \({\it Exponential}(m)\) random variable, with \(m>0\).

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

  The mean is $$ E[X] = {1\over m} $$

      (%i1) load ("distrib")$

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

  Categories: Package distrib ·

Function: var_exp (m) ¶

  Returns the variance of an \({\it Exponential}(m)\) random variable, with \(m>0\).

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

  The variance is $$ V[X] = {1\over m^2} $$

      (%i1) load ("distrib")$

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

  Categories: Package distrib ·

Function: std_exp (m) ¶

  Returns the standard deviation of an \({\it Exponential}(m)\) random variable, with \(m>0\).

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

  The standard deviation is $$ D[X] = {1\over m} $$

      (%i1) load ("distrib")$

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

  Categories: Package distrib ·

Function: skewness_exp (m) ¶

  Returns the skewness coefficient of an \({\it Exponential}(m)\) random variable, with \(m>0\).

  The \({\it Exponential}(m)\) random variable is equivalent to the \({\it 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 \({\it Exponential}(m)\) random variable, with \(m>0\).

  The \({\it Exponential}(m)\) random variable is equivalent to the \({\it 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 \({\it 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 ·

#### 54.2.8 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 \({\it Lognormal}(m,s)\) random variable, with \(s>0\). To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x; m, s) = \cases{ \displaystyle{1\over x s \sqrt{2\pi}} \exp\left(-\displaystyle{\left(\log x - m\right)^2\over 2s^2}\right) & for $x \ge 0$ \cr \cr 0 & for $x < 0$ } $$

  Categories: Package distrib ·

Function: cdf_lognormal (x,m,s) ¶

  Returns the value at x of the cumulative distribution function of a \({\it 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 $$ F(x; m, s) = \cases{ \displaystyle{1\over 2}\left[1+{\rm erf}\left({\log x - m\over s\sqrt{2}}\right)\right] & for $x > 0$ \cr \cr 0 & for $x \le 0$ } $$

      (%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 \({\it 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 \({\it Lognormal}(m,s)\) random variable, with \(s>0\). To make use of this function, write first `load("distrib")`.

  The mean is $$ E[X] = \exp\left(m+{s^2\over 2}\right) $$

  Categories: Package distrib ·

Function: var_lognormal (m,s) ¶

  Returns the variance of a \({\it Lognormal}(m,s)\) random variable, with \(s>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = \left(\exp\left(s^2\right) - 1\right) \exp\left(2m+s^2\right) $$

  Categories: Package distrib ·

Function: std_lognormal (m,s) ¶

  Returns the standard deviation of a \({\it Lognormal}(m,s)\) random variable, with \(s>0\). To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ D[X] = \sqrt{\left(\exp\left(s^2\right) - 1\right)} \exp\left(m+{s^2\over 2}\right) $$

  Categories: Package distrib ·

Function: skewness_lognormal (m,s) ¶

  Returns the skewness coefficient of a \({\it Lognormal}(m,s)\) random variable, with \(s>0\). To make use of this function, write first `load("distrib")`.

  The skewness coefficient is $$ SK[X] = \left(\exp\left(s^2\right)+2\right)\sqrt{\exp\left(s^2\right)-1} $$

  Categories: Package distrib ·

Function: kurtosis_lognormal (m,s) ¶

  Returns the kurtosis coefficient of a \({\it Lognormal}(m,s)\) random variable, with \(s>0\). To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = \exp\left(4s^2\right)+2\exp\left(3s^2\right)+3\exp\left(2s^2\right)-3 $$

  Categories: Package distrib ·

Function: random_lognormal (m,s)
random_lognormal (m,s,n) ¶

  Returns a \({\it 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 ·

#### 54.2.9 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\left(a,b\right)\) 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 $$ f(x; a, b) = {x^{a-1}e^{-x/b}\over b^a \Gamma(a)} $$

  Categories: Package distrib ·

Function: cdf_gamma (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \(\Gamma\left(a,b\right)\) random variable, with \(a,b>0\).

  The cdf is $$ F(x; a, b) = \cases{ 1-Q(a,{x\over b}) & for $x \ge 0$ \cr \cr 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\left(a,b\right)\) 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\left(a,b\right)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The mean is $$ E[X] = ab $$

  Categories: Package distrib ·

Function: var_gamma (a,b) ¶

  Returns the variance of a \(\Gamma\left(a,b\right)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = ab^2 $$

  Categories: Package distrib ·

Function: std_gamma (a,b) ¶

  Returns the standard deviation of a \(\Gamma\left(a,b\right)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ D[X] = b\sqrt{a} $$

  Categories: Package distrib ·

Function: skewness_gamma (a,b) ¶

  Returns the skewness coefficient of a \(\Gamma\left(a,b\right)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The skewness coefficient is $$ SK[X] = {2\over \sqrt{a}} $$

  Categories: Package distrib ·

Function: kurtosis_gamma (a,b) ¶

  Returns the kurtosis coefficient of a \(\Gamma\left(a,b\right)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = {6\over a} $$

  Categories: Package distrib ·

Function: random_gamma (a,b)
random_gamma (a,b,n) ¶

  Returns a \(\Gamma\left(a,b\right)\) 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 \ge 1,\) Cheng, R.C.H. and Feast, G.M. (1979). Some simple gamma variate generators. Appl. Stat., 28, 3, 290-295.

  For \(0 \lt a \lt 1,\) Ahrens, J.H. and Dieter, U. (1974). Computer methods for sampling from gamma, , poisson and binomial distributions. Computing, 12, 223-246.

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

  Categories: Package distrib · Random numbers ·

#### 54.2.10 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 \({\it Beta}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x; a, b) = \cases{ \displaystyle{x^{a-1}(1-x)^{b-1} \over B(a,b)} & for $0 \le x \le 1$ \cr \cr 0 & otherwise } $$

  Categories: Package distrib ·

Function: cdf_beta (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Beta}(a,b)\) random variable, with \(a,b>0\).

  The cdf is $$ F(x; a, b) = \cases{ 0 & $x < 0$ \cr I_x(a,b) & $0 \le x \le 1$ \cr 1 & $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 \({\it 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 \({\it Beta}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The mean is $$ E[X] = {a\over a+b} $$

  Categories: Package distrib ·

Function: var_beta (a,b) ¶

  Returns the variance of a \({\it Beta}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = {ab \over (a+b)^2(a+b+1)} $$

  Categories: Package distrib ·

Function: std_beta (a,b) ¶

  Returns the standard deviation of a \({\it Beta}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ D[X] = {1\over a+b}\sqrt{ab\over a+b+1} $$

  Categories: Package distrib ·

Function: skewness_beta (a,b) ¶

  Returns the skewness coefficient of a \({\it Beta}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The skewness coefficient is $$ SK[X] = {2(b-a)\sqrt{a+b+1} \over (a+b+2)\sqrt{ab}} $$

  Categories: Package distrib ·

Function: kurtosis_beta (a,b) ¶

  Returns the kurtosis coefficient of a \({\it Beta}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = {3(a+b+1)\left(2(a+b)^2+ab(a+b-6)\right) \over ab(a+b+2)(a+b+3)} - 3 $$

  Categories: Package distrib ·

Function: random_beta (a,b)
random_beta (a,b,n) ¶

  Returns a \({\it 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 ·

#### 54.2.11 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 \({\it ContinuousUniform}(a,b)\) random variable, with \(a \lt b.\) To make use of this function, write first `load("distrib")`.

  The pdf $$ f(x; a, b) = \cases{ \displaystyle{1\over b-a} & for $0 \le x \le 1$ \cr \cr 0 & otherwise } $$

  and is 0 otherwise.

  Categories: Package distrib ·

Function: cdf_continuous_uniform (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it ContinuousUniform}(a,b)\) random variable, with \(a \lt b.\) To make use of this function, write first `load("distrib")`.

  The cdf is $$ F(x; a, b) = \cases{ 0 & for $x < a$ \cr \cr \displaystyle{x-a\over b-a} & for $a \le x \le b$ \cr \cr 1 & for $x > b$ } $$

  Categories: Package distrib ·

Function: quantile_continuous_uniform (q,a,b) ¶

  Returns the q-quantile of a \({\it ContinuousUniform}(a,b)\) random variable, with \(a \lt 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 \({\it ContinuousUniform}(a,b)\) random variable, with \(a \lt b.\) To make use of this function, write first `load("distrib")`.

  The mean is $$ E[X] = {a+b\over 2} $$

  Categories: Package distrib ·

Function: var_continuous_uniform (a,b) ¶

  Returns the variance of a \({\it ContinuousUniform}(a,b)\) random variable, with \(a \lt b.\) To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = {(b-a)^2\over 12} $$

  Categories: Package distrib ·

Function: std_continuous_uniform (a,b) ¶

  Returns the standard deviation of a \({\it ContinuousUniform}(a,b)\) random variable, with \(a \lt b.\) To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ D[X] = {b-a \over 2\sqrt{3}} $$

  Categories: Package distrib ·

Function: skewness_continuous_uniform (a,b) ¶

  Returns the skewness coefficient of a \({\it ContinuousUniform}(a,b)\) random variable, with \(a \lt 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 \({\it ContinuousUniform}(a,b)\) random variable, with \(a \lt b.\) To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = -{6\over5} $$

  Categories: Package distrib ·

Function: random_continuous_uniform (a,b)
random_continuous_uniform (a,b,n) ¶

  Returns a \({\it ContinuousUniform}(a,b)\) random variate, with \(a \lt 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 ·

#### 54.2.12 Logistic Random Variable ¶

The logistic distribution is a continuous distribution where its cumulative distribution function is the logistic function.

Function: pdf_logistic (x,a,b) ¶

  Returns the value at x of the density function of a \({\it Logistic}(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 $$ f(x; a, b) = {e^{-(x-a)/b} \over b\left(1 + e^{-(x-a)/b}\right)^2} $$

  Categories: Package distrib ·

Function: cdf_logistic (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Logistic}(a,b)\) random variable , with \(b>0\). To make use of this function, write first `load("distrib")`.

  The cdf is $$ F(x; a, b) = {1\over 1+e^{-(x-a)/b}} $$

  Categories: Package distrib ·

Function: quantile_logistic (q,a,b) ¶

  Returns the q-quantile of a \({\it Logistic}(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 \({\it Logistic}(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 \({\it Logistic}(a,b)\) random variable , with \(b>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = {\pi^2 b^2 \over 3} $$

  Categories: Package distrib ·

Function: std_logistic (a,b) ¶

  Returns the standard deviation of a \({\it Logistic}(a,b)\) random variable , with \(b>0\). To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ D[X] = {\pi b\over \sqrt{3}} $$

  Categories: Package distrib ·

Function: skewness_logistic (a,b) ¶

  Returns the skewness coefficient of a \({\it Logistic}(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 \({\it Logistic}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = {6\over 5} $$

  Categories: Package distrib ·

Function: random_logistic (a,b)
random_logistic (a,b,n) ¶

  Returns a \({\it Logistic}(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 ·

#### 54.2.13 Pareto Random Variable ¶

Function: pdf_pareto (x,a,b) ¶

  Returns the value at x of the density function of a \({\it Pareto}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x; a, b) = \cases{ \displaystyle{a b^a \over x^{a+1}} & for $x \ge b$ \cr \cr 0 & for $x < b$ } $$

  Categories: Package distrib ·

Function: cdf_pareto (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Pareto}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The cdf is $$ F(x; a, b) = \cases{ 1-\left(\displaystyle{b\over x}\right)^a & for $x \ge b$\cr 0 & for $x < b$ } $$

  Categories: Package distrib ·

Function: quantile_pareto (q,a,b) ¶

  Returns the q-quantile of a \({\it 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 \({\it 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] = {ab\over a-1} $$

  Categories: Package distrib ·

Function: var_pareto (a,b) ¶

  Returns the variance of a \({\it Pareto}(a,b)\) random variable, with \(a>2,b>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = {ab^2\over (a-2)(a-1)^2} $$

  Categories: Package distrib ·

Function: std_pareto (a,b) ¶

  Returns the standard deviation of a \({\it Pareto}(a,b)\) random variable, with \(a>2,b>0\). To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ D[X] = {b\over a-1} \sqrt{a\over a-2} $$

  Categories: Package distrib ·

Function: skewness_pareto (a,b) ¶

  Returns the skewness coefficient of a \({\it Pareto}(a,b)\) random variable, with \(a>3,b>0\). To make use of this function, write first `load("distrib")`.

  The skewness coefficient is $$ SK[X] = {2(a+1)\over a-3} \sqrt{a-2\over a} $$

  Categories: Package distrib ·

Function: kurtosis_pareto (a,b) ¶

  Returns the kurtosis coefficient of a \({\it Pareto}(a,b)\) random variable, with \(a>4,b>0\). To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = {6\left(a^3+a^2-6*a-2\right) \over a(a-3)(a-4)} - 3 $$

  Categories: Package distrib ·

Function: random_pareto (a,b)
random_pareto (a,b,n) ¶

  Returns a \({\it 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 ·

#### 54.2.14 Weibull Random Variable ¶

Function: pdf_weibull (x,a,b) ¶

  Returns the value at x of the density function of a \({\it Weibull}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x; a, b) = \cases{ \displaystyle{1\over b} \left({x\over b}\right)^{a-1} e^{-(x/b)^a} & for $x \ge 0$ \cr \cr 0 & for $x < 0$ } $$

  Categories: Package distrib ·

Function: cdf_weibull (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Weibull}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The cdf is $$ F(x; a, b) = \cases{ 1 - e^{-(x/b)^a} & for $x \ge 0$ \cr 0 & for $x < 0$ } $$

  Categories: Package distrib ·

Function: quantile_weibull (q,a,b) ¶

  Returns the q-quantile of a \({\it 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 \({\it Weibull}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The mean is $$ E[X] = b\Gamma\left(1+{1\over a}\right) $$

  Categories: Package distrib ·

Function: var_weibull (a,b) ¶

  Returns the variance of a \({\it Weibull}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = b^2\left[\Gamma\left(1+{2\over a}\right) - \Gamma\left(1+{1\over a}\right)^2\right] $$

  Categories: Package distrib ·

Function: std_weibull (a,b) ¶

  Returns the standard deviation of a \({\it Weibull}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ D[X] = b\sqrt{\Gamma\left(1+{2\over a}\right) - \Gamma\left(1+{1\over a}\right)^2} $$

  Categories: Package distrib ·

Function: skewness_weibull (a,b) ¶

  Returns the skewness coefficient of a \({\it Weibull}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The skewness coefficient is $$ SK[X] = {\displaystyle\Gamma\left(1+{3\over a}\right) -3\Gamma\left(1+{1\over a}\right)\Gamma\left(1+{2\over a}\right)+2\Gamma\left(1+{1\over a}\right)^3 \over \displaystyle\left[\Gamma\left(1+{2\over a}\right)-\Gamma\left(1+{1\over a}\right)^2\right]^{3/2} } $$

  Categories: Package distrib ·

Function: kurtosis_weibull (a,b) ¶

  Returns the kurtosis coefficient of a \({\it Weibull}(a,b)\) random variable, with \(a,b>0\). To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = { \Gamma_4 - 4\Gamma_1 \Gamma_3 + 6\Gamma_1^2 \Gamma_2 - 3 \Gamma_1^4 \over \left[\Gamma_2 - \Gamma_1^2\right]^2 } - 3 $$

  where \(\Gamma_k = \Gamma\left(1+k/a\right).\)

  Categories: Package distrib ·

Function: random_weibull (a,b)
random_weibull (a,b,n) ¶

  Returns a \({\it 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 ·

#### 54.2.15 Rayleigh Random Variable ¶

The Rayleigh distribution coincides with the \(\chi^2\) distribution with two degrees of freedom.

Function: pdf_rayleigh (x,b) ¶

  Returns the value at x of the density function of a \({\it Rayleigh}(b)\) random variable, with \(b>0\).

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

  The pdf is $$ f(x; b) = \cases{ 2b^2 x e^{-b^2 x^2} & for $x \ge 0$ \cr 0 & for $x < 0$ } $$

      (%i1) load ("distrib")$

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

  Categories: Package distrib ·

Function: cdf_rayleigh (x,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Rayleigh}(b)\) random variable, with \(b>0\).

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

  The cdf is $$ F(x; b) = \cases{ 1 - e^{-b^2 x^2} & for $x \ge 0$\cr 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 \({\it 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 \({\it Rayleigh}(b)\) random variable is equivalent to the \({\it Weibull}(2,1/b)\) .

      (%i1) load ("distrib")$

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

  Categories: Package distrib ·

Function: mean_rayleigh (b) ¶

  Returns the mean of a \({\it Rayleigh}(b)\) random variable, with \(b>0\).

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

  The mean is $$ E[X] = {\sqrt{\pi}\over 2b} $$

      (%i1) load ("distrib")$

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

  Categories: Package distrib ·

Function: var_rayleigh (b) ¶

  Returns the variance of a \({\it Rayleigh}(b)\) random variable, with \(b>0\).

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

  The variance is $$ V[X] = {1\over b^2}\left(1-{\pi \over 4}\right) $$

      (%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 \({\it Rayleigh}(b)\) random variable, with \(b>0\).

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

  The standard deviation is $$ D[X] = {1\over b}\sqrt{\displaystyle 1 - {\pi\over 4}} $$

      (%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 \({\it Rayleigh}(b)\) random variable, with \(b>0\).

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

  The skewness coefficient is $$ SK[X] = {2\sqrt{\pi}(\pi - 3)\over (4-\pi)^{3/2}} $$

      (%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 \({\it Rayleigh}(b)\) random variable, with \(b>0\).

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

  The kurtosis coefficient is $$ KU[X] = {32-3\pi\over (4-\pi)^2} - 3 $$

      (%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 \({\it 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 ·

#### 54.2.16 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 \({\it 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 $$ f(x; a, b) = {1\over 2b}\exp\left(-{|x-a|\over b}\right) $$

  Categories: Package distrib ·

Function: cdf_laplace (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Laplace}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The cdf is $$ F(x; a, b) = \cases{ \displaystyle{1\over 2} \exp\left({x-a\over b}\right) & for $x < a$\cr \cr 1-\displaystyle{1\over 2} \exp\left({x-a\over b}\right) & for $x \ge a$ } $$

  Categories: Package distrib ·

Function: quantile_laplace (q,a,b) ¶

  Returns the q-quantile of a \({\it 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 \({\it 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 \({\it Laplace}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = 2b^2 $$

  Categories: Package distrib ·

Function: std_laplace (a,b) ¶

  Returns the standard deviation of a \({\it 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 \({\it 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 \({\it 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 \({\it 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 ·

#### 54.2.17 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 \({\it Cauchy}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x; a, b) = {b\over \pi\left((x-a)^2+b^2\right)} $$

  Categories: Package distrib ·

Function: cdf_cauchy (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Cauchy}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The cdf is $$ F(x; a, b) = {1\over 2} + {1\over \pi} \tan^{-1} {x-a\over b} $$

  Categories: Package distrib ·

Function: quantile_cauchy (q,a,b) ¶

  Returns the q-quantile of a \({\it 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 \({\it 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 ·

#### 54.2.18 Gumbel Random Variable ¶

Function: pdf_gumbel (x,a,b) ¶

  Returns the value at x of the density function of a \({\it Gumbel}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x; a, b) = {1\over b} \exp\left[{a-x\over b} - \exp\left({a-x\over b}\right)\right] $$

  Categories: Package distrib ·

Function: cdf_gumbel (x,a,b) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Gumbel}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The cdf is $$ F(x; a, b) = \exp\left[-\exp\left({a-x\over b}\right)\right] $$

  Categories: Package distrib ·

Function: quantile_gumbel (q,a,b) ¶

  Returns the q-quantile of a \({\it 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 \({\it Gumbel}(a,b)\) random variable, with \(b>0\).

  The mean is $$ E[X] = a+b\gamma $$

      (%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 \({\it Gumbel}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = {\pi^2\over 6} b^2 $$

  Categories: Package distrib ·

Function: std_gumbel (a,b) ¶

  Returns the standard deviation of a \({\it Gumbel}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ D[X] = {\pi \over \sqrt{6}} b $$

  Categories: Package distrib ·

Function: skewness_gumbel (a,b) ¶

  Returns the skewness coefficient of a \({\it Gumbel}(a,b)\) random variable, with \(b>0\).

  The skewness coefficient is $$ SK[X] = {12\sqrt{6}\over \pi^3} \zeta(3) $$

      (%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 \({\it Gumbel}(a,b)\) random variable, with \(b>0\). To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = {12\over 5} $$

  Categories: Package distrib · Package distrib ·

Function: random_gumbel (a,b)
random_gumbel (a,b,n) ¶

  Returns a \({\it 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 ·

### 54.3 Functions and Variables for discrete distributions ¶

Maxima knows the following kinds of discrete distributions

#### 54.3.1 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")`.

  Note that \(i=1\) corresponds to the first element of \(v\).

      (%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 cumulative 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)            [4, 4, 2, 4, 2, 2, 4, 2, 2, 4]

  Categories: Package distrib · Random numbers ·

#### 54.3.2 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 probability \(p\).

For example, a biased coin that comes up heads with probability \(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 \({\it 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 $$ f(x; n, p) = {n\choose x} (1-p)^{n-x}p^x $$

  Categories: Package distrib ·

Function: cdf_binomial (x,n,p) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Binomial}(n,p)\) random variable, with \(0 \leq p \leq 1\) and \(n\) a positive integer.

  The cdf is $$ F(x; n, p) = I_{1-p}(n-\lfloor x \rfloor, \lfloor x \rfloor + 1) $$

  where \(I_z(a,b)\) is the beta_incomplete_regularized function.

      (%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 \({\it 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 \({\it 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] = np $$

  Categories: Package distrib ·

Function: var_binomial (n,p) ¶

  Returns the variance of a \({\it 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] = np(1-p) $$

  Categories: Package distrib ·

Function: std_binomial (n,p) ¶

  Returns the standard deviation of a \({\it 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{np(1-p)} $$

  Categories: Package distrib ·

Function: skewness_binomial (n,p) ¶

  Returns the skewness coefficient of a \({\it 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 $$ SK[X] = {1-2p\over \sqrt{np(1-p)}} $$

  Categories: Package distrib ·

Function: kurtosis_binomial (n,p) ¶

  Returns the kurtosis coefficient of a \({\it 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 $$ KU[X] = {1-6p(1-p)\over np(1-p)} $$

  Categories: Package distrib ·

Function: random_binomial (n,p)
random_binomial (n,p,m) ¶

  Returns a \({\it 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 ·

#### 54.3.3 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 \({\it Poisson}(m)\) random variable, with \(m>0\). To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x; m) = {m^x e^{-m}\over x!} $$

  Categories: Package distrib ·

Function: cdf_poisson (x,m) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Poisson}(m)\) random variable, with \(m>0\).

  The cdf is $$ F(x; m) = Q(\lfloor x \rfloor + 1, m) $$

  where \(Q(x,m)\) is the gamma_incomplete_regularized function.

      (%i1) load ("distrib")$

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

      (%i3) float(%);
      (%o3)                  0.26502591529736186

  Categories: Package distrib ·

Function: quantile_poisson (q,m) ¶

  Returns the q-quantile of a \({\it 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 \({\it 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 \({\it 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 \({\it Poisson}(m)\) random variable, with \(m>0\). To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ V[X] = \sqrt{m} $$

  Categories: Package distrib ·

Function: skewness_poisson (m) ¶

  Returns the skewness coefficient of a \({\it Poisson}(m)\) random variable, with \(m>0\). To make use of this function, write first `load("distrib")`.

  The skewness is $$ SK[X] = {1\over \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 $$ KU[X] = {1\over m} $$

  Categories: Package distrib ·

Function: random_poisson (m)
random_poisson (m,n) ¶

  Returns a \({\it 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 ·

#### 54.3.4 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 probability \(1-p\).

It is equivalent to the \({\it Binomial}(1,p)\) distribution (see Binomial Random Variable)

Function: pdf_bernoulli (x,p) ¶

  Returns the value at x of the probability function of a \({\it Bernoulli}(p)\) random variable, with \(0 \leq p \leq 1\).

  The \({\it Bernoulli}(p)\) random variable is equivalent to the \({\it Binomial}(1,p)\) .

  The mean is $$ f(x; p) = p^x (1-p)^{1-x} $$

      (%i1) load ("distrib")$

      (%i2) pdf_bernoulli(1,p);
      (%o2) if equal(p, 0) then 0 elseif equal(p, 1) then 1 else p

  Categories: Package distrib ·

Function: cdf_bernoulli (x,p) ¶

  Returns the value at x of the cumulative distribution function of a \({\it 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; p) = I_{1-p}(1-\lfloor x \rfloor, \lfloor x \rfloor + 1) $$

  Categories: Package distrib ·

Function: quantile_bernoulli (q,p) ¶

  Returns the q-quantile of a \({\it 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 \({\it Bernoulli}(p)\) random variable, with \(0 \leq p \leq 1\).

  The \({\it Bernoulli}(p)\) random variable is equivalent to the \({\it 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 \({\it Bernoulli}(p)\) random variable, with \(0 \leq p \leq 1\).

  The \({\it Bernoulli}(p)\) random variable is equivalent to the \({\it Binomial}(1,p)\) .

  The variance is $$ V[X] = p(1-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 \({\it Bernoulli}(p)\) random variable, with \(0 \leq p \leq 1\).

  The \({\it Bernoulli}(p)\) random variable is equivalent to the \({\it Binomial}(1,p)\) .

  The standard deviation is $$ D[X] = \sqrt{p(1-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 \({\it Bernoulli}(p)\) random variable, with \(0 \leq p \leq 1\).

  The \({\it Bernoulli}(p)\) random variable is equivalent to the \({\it Binomial}(1,p)\) .

  The skewness coefficient is $$ SK[X] = {1-2p \over \sqrt{p(1-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 \({\it Bernoulli}(p)\) random variable, with \(0 \leq p \leq 1\).

  The \({\it Bernoulli}(p)\) random variable is equivalent to the \({\it Binomial}(1,p)\) .

  The kurtosis coefficient is $$ KU[X] = {1-6p(1-p) \over p(1-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 \({\it 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 ·

#### 54.3.5 Geometric Random Variable ¶

The Geometric distribution 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 probability \(p\). Then the probability of \(k-1\) tails in a row followed by heads is given by the \({\it Geometric}(p)\) distribution.

Function: pdf_geometric (x,p) ¶

  Returns the value at x of the probability function of a \({\it Geometric}(p)\) random variable, with \(0 < p \leq 1\)

  The pdf is $$ f(x; p) = 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: cdf_geometric (x,p) ¶

  Returns the value at x of the cumulative distribution function of a \({\it Geometric}(p)\) random variable, with \(0 < p \leq 1\)

  The cdf is $$ 1-(1-p)^{1 + \lfloor x \rfloor} $$

  `load("distrib")` loads this function.

  Categories: Package distrib ·

Function: quantile_geometric (q,p) ¶

  Returns the q-quantile of a \({\it Geometric}(p)\) random variable, with \(0 \lt p \le 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 \({\it Geometric}(p)\) random variable, with \(0 < p \leq 1\).

  The mean is $$ E[X] = {1\over p} - 1 $$

  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 \({\it Geometric}(p)\) random variable, with \(0 < p \leq 1\).

  The variance is $$ V[X] = {1-p\over p^2} $$

  `load("distrib")` loads this function.

  Categories: Package distrib ·

Function: std_geometric (p) ¶

  Returns the standard deviation of a \({\it Geometric}(p)\) random variable, with \(0 < p \leq 1\).

  $$ D[X] = {\sqrt{1-p} \over p} $$

  `load("distrib")` loads this function.

  Categories: Package distrib ·

Function: skewness_geometric (p) ¶

  Returns the skewness coefficient of a \({\it Geometric}(p)\) random variable, with \(0 < p \leq 1\).

  The skewness coefficient is $$ SK[X] = {2-p \over \sqrt{1-p}} $$

  `load("distrib")` loads this function.

  Categories: Package distrib ·

Function: kurtosis_geometric (p) ¶

  Returns the kurtosis coefficient of a geometric random variable \({\it Geometric}(p)\) , with \(0 < p \leq 1\).

  The kurtosis coefficient is $$ KU[X] = {p^2-6p+6 \over 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 \({\it Geometric}(p)\) distribution, with \(0 \lt p \le 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 ·

#### 54.3.6 Discrete Uniform Random Variable ¶

The Discrete uniform distribution is a discrete probability 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 \({\it DiscreteUniform}(1/6)\) distribution.

Function: pdf_discrete_uniform (x,n) ¶

  Returns the value at x of the probability function of a \({\it DiscreteUniform}(n)\) random variable, with \(n\) a strictly positive integer. To make use of this function, write first `load("distrib")`.

  The pdf is $$ f(x,n) = {1\over n} $$

  Categories: Package distrib ·

Function: cdf_discrete_uniform (x,n) ¶

  Returns the value at x of the cumulative distribution function of a \({\it DiscreteUniform}(n)\) random variable, with \(n\) a strictly positive integer. To make use of this function, write first `load("distrib")`.

  The cdf is $$ F(x; n) = {\lfloor x \rfloor \over n} $$

  Categories: Package distrib ·

Function: quantile_discrete_uniform (q,n) ¶

  Returns the q-quantile of a \({\it 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 \({\it DiscreteUniform}(n)\) random variable, with \(n\) a strictly positive integer. To make use of this function, write first `load("distrib")`.

  The mean is $$ E[X] = {n+1\over 2} $$

  Categories: Package distrib ·

Function: var_discrete_uniform (n) ¶

  Returns the variance of a \({\it DiscreteUniform}(n)\) random variable, with \(n\) a strictly positive integer. To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = {n^2-1 \over 12} $$

  Categories: Package distrib ·

Function: std_discrete_uniform (n) ¶

  Returns the standard deviation of a \({\it DiscreteUniform}(n)\) random variable, with \(n\) a strictly positive integer. To make use of this function, write first `load("distrib")`.

  The standard deviation is $$ D[X] = {\sqrt{n^2-1} \over 2\sqrt{3}} $$

  Categories: Package distrib ·

Function: skewness_discrete_uniform (n) ¶

  Returns the skewness coefficient of a \({\it 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 \({\it DiscreteUniform}(n)\) random variable, with \(n\) a strictly positive integer. To make use of this function, write first `load("distrib")`.

  The kurtosis coefficient is $$ KU[X] = - {6(n^2+1)\over 5 (n^2-1)} $$

  Categories: Package distrib ·

Function: random_discrete_uniform (n)
random_discrete_uniform (n,m) ¶

  Returns a \({\it 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 ·

#### 54.3.7 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 replacement. 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 \({\it 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 $$ f(x; n_1, n_2, n) = {\displaystyle{n_1\choose x} {n_2 \choose n-x} \over \displaystyle{n_2+n_1 \choose n}} $$

  Categories: Package distrib ·

Function: cdf_hypergeometric (x,n_1,n_2,n) ¶

  Returns the value at x of the cumulative distribution function of a \({\it 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 $$ F(x; n_1, n_2, n) = {n_2+n_1\choose n}^{-1} \sum_{k=0}^{\lfloor x \rfloor} {n_1 \choose k} {n_2 \choose n - k} $$

  Categories: Package distrib ·

Function: quantile_hypergeometric (q,n1,n2,n) ¶

  Returns the q-quantile of a \({\it 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 \({\it 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 $$ E[X] = {n n_1\over n_2+n_1} $$

  Categories: Package distrib ·

Function: var_hypergeometric (n1,n2,n) ¶

  Returns the variance of a hypergeometric random variable \({\it Hypergeometric}(n_1,n_2,n)\) , with \(n_1\), \(n_2\) and \(n\) non negative integers and \(n \le n_1 + n_2.\) To make use of this function, write first `load("distrib")`.

  The variance is $$ V[X] = {n n_1 n_2 (n_1 + n_2 - n) \over (n_1 + n_2 - 1) (n_1 + n_2)^2} $$

  Categories: Package distrib ·

Function: std_hypergeometric (n_1,n_2,n) ¶

  Returns the standard deviation of a \({\it 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 $$ D[X] = {1\over n_1+n_2}\sqrt{n n_1 n_2 (n_1 + n_2 - n) \over n_1+n_2-1} $$

  Categories: Package distrib ·

Function: skewness_hypergeometric (n_1,n_2,n) ¶

  Returns the skewness coefficient of a \({\it 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 $$ SK[X] = {(n_2-n_2)(n_1+n_2-2n)\over n_1+n_2-2} \sqrt{n_1+n_2-1 \over n n_1 n_2 (n_1+n_2-n)} $$

  Categories: Package distrib ·

Function: kurtosis_hypergeometric (n_1,n_2,n) ¶

  Returns the kurtosis coefficient of a \({\it 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 $$ \eqalign{ KU[X] = & \left[{C(1)C(0)^2 \over n n_1 n_2 C(3)C(2)C(n)}\right. \cr & \times \left.\left( {3n_1n_2\left((n-2)C(0)^2+6nC(n)-n^2C(0)\right) \over C(0)^2 } -6nC(n) + C(0)C(-1) \right)\right] \cr &-3 } $$

  where \(C(k) = n_1+n_2-k.\)

  Categories: Package distrib ·

Function: random_hypergeometric (n1,n2,n)
random_hypergeometric (n1,n2,n,m) ¶

  Returns a \({\it Hypergeometric}(n1,n2,n)\) random variate, with n1, n2 and n non negative integers and \(n \le n_1 + n_2.\) 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 ·

#### 54.3.8 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 probability \(p\) and “failure” with probability \(1-p\). We observe the sequence until a predefined number \(r\) of successes have occurred. Then the number of failures seen will have a \({\it NegativeBinomial}(r,p)\) distribution.

Function: pdf_negative_binomial (x,n,p) ¶

  Returns the value at x of the probability function of a \({\it 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 $$ f(x; n, p) = {x+n-1 \choose n-1} (1-p)^xp^n $$

  Categories: Package distrib ·

Function: cdf_negative_binomial (x,n,p) ¶

  Returns the value at x of the cumulative distribution function of a \({\it NegativeBinomial}(n,p)\) random variable, with \(0 < p \leq 1\) and \(n\) a positive number.

  The cdf is $$ F(x; n, p) = I_p(n,\lfloor x \rfloor + 1) $$

  where \(I_p(a,b)\) is the beta_incomplete_regularized function.

      (%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 \({\it 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 \({\it 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 $$ E[X] = {n(1-p)\over p} $$

  Categories: Package distrib ·

Function: var_negative_binomial (n,p) ¶

  Returns the variance of a \({\it 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 $$ V[X] = {n(1-p)\over p^2} $$

  Categories: Package distrib ·

Function: std_negative_binomial (n,p) ¶

  Returns the standard deviation of a \({\it 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 $$ D[X] = {\sqrt{n(1-p)}\over p} $$

  Categories: Package distrib ·

Function: skewness_negative_binomial (n,p) ¶

  Returns the skewness coefficient of a \({\it 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 $$ SK[X] = {2-p \over \sqrt{n(1-p)}} $$

  Categories: Package distrib ·

Function: kurtosis_negative_binomial (n,p) ¶

  Returns the kurtosis coefficient of a \({\it 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 $$ KU[X] = {p^2-6p+6 \over n(1-p)} $$

  Categories: Package distrib ·

Function: random_negative_binomial (n,p)
random_negative_binomial (n,p,m) ¶

  Returns a \({\it 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 ·

JavaScript license information