Maxima Manual: Functions and Variables for discrete distributions

Previous: Functions and Variables for continuous distributions, Nach oben: Package distrib [Inhalt][Index]

### 41.3 Functions and Variables for discrete distributions

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

  Examples:

      (%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

Function: cdf_general_finite_discrete (x, v)

  Returns the value at x of the distribution function of a general finite discrete random variable, with vector probabilities v.

  See `pdf_general_finite_discrete` for more details.

  Examples:

      (%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

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.

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.

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.

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.

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.

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.

Function: random_general_finite_discrete (v)
Function: 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.

  Examples:

      (%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, 2, 2, 3, 2, 4, 4, 1, 2, 2]

Function: pdf_binomial (x, n, p)

  Returns the value at x of the probability function of a Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: cdf_binomial (x, n, p)

  Returns the value at x of the distribution function of a Binomial(n,p) random variable, with 0<p<1 and n a positive integer.

      (%i1) load ("distrib")$
      (%i2) cdf_binomial(5,7,1/6);
                                  7775
      (%o2)                       ----
                                  7776
      (%i3) float(%);
      (%o3)               .9998713991769548

Function: quantile_binomial (q, n, p)

  Returns the q-quantile of a Binomial(n,p) random variable, with 0<p<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")`.

Function: mean_binomial (n, p)

  Returns the mean of a Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: var_binomial (n, p)

  Returns the variance of a Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: std_binomial (n, p)

  Returns the standard deviation of a Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: skewness_binomial (n, p)

  Returns the skewness coefficient of a Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: kurtosis_binomial (n, p)

  Returns the kurtosis coefficient of a Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

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

  Returns a Binomial(n,p) random variate, with 0<p<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")`.

Function: pdf_poisson (x, m)

  Returns the value at x of the probability function of a Poisson(m) random variable, with m>0. To make use of this function, write first `load("distrib")`.

Function: cdf_poisson (x, m)

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

      (%i1) load ("distrib")$
      (%i2) cdf_poisson(3,5);
      (%o2)       gamma_incomplete_regularized(4, 5)
      (%i3) float(%);
      (%o3)               .2650259152973623

Function: quantile_poisson (q, m)

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

Function: mean_poisson (m)

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

Function: var_poisson (m)

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

Function: std_poisson (m)

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

Function: skewness_poisson (m)

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

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

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

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

  The implemented algorithm is the one described in Ahrens, J.H. and Dieter, U. (1982) Computer Generation of Poisson Deviates From Modified Normal Distributions. ACM Trans. Math. Software, 8, 2, June,163-179.

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

Function: pdf_bernoulli (x, p)

  Returns the value at x of the probability function of a Bernoulli(p) random variable, with 0<p<1.

  The Bernoulli(p) random variable is equivalent to the Binomial(1,p), therefore when Maxima has not enough information to get the result, a noun form based on the binomial probability function is returned.

      (%i1) load ("distrib")$
      (%i2) pdf_bernoulli(1,p);
      (%o2)                 pdf_binomial(1, 1, p)
      (%i3) assume(0<p,p<1)$ pdf_bernoulli(1,p);
      (%o4)                           p

Function: cdf_bernoulli (x, p)

  Returns the value at x of the distribution function of a Bernoulli(p) random variable, with 0<p<1. To make use of this function, write first `load("distrib")`.

Function: quantile_bernoulli (q, p)

  Returns the q-quantile of a Bernoulli(p) random variable, with 0<p<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")`.

Function: mean_bernoulli (p)

  Returns the mean of a Bernoulli(p) random variable, with 0<p<1.

  The Bernoulli(p) random variable is equivalent to the Binomial(1,p), therefore when Maxima has not enough information to get the result, a noun form based on the binomial mean is returned.

      (%i1) load ("distrib")$
      (%i2) mean_bernoulli(p);
      (%o2)                  mean_binomial(1, p)
      (%i3) assume(0<p,p<1)$ mean_bernoulli(p);
      (%o4)                           p

Function: var_bernoulli (p)

  Returns the variance of a Bernoulli(p) random variable, with 0<p<1.

  The Bernoulli(p) random variable is equivalent to the Binomial(1,p), therefore when Maxima has not enough information to get the result, a noun form based on the binomial variance is returned.

      (%i1) load ("distrib")$
      (%i2) var_bernoulli(p);
      (%o2)                  var_binomial(1, p)
      (%i3) assume(0<p,p<1)$ var_bernoulli(p);
      (%o4)                       (1 - p) p

Function: std_bernoulli (p)

  Returns the standard deviation of a Bernoulli(p) random variable, with 0<p<1.

  The Bernoulli(p) random variable is equivalent to the Binomial(1,p), therefore when Maxima has not enough information to get the result, a noun form based on the binomial standard deviation is returned.

      (%i1) load ("distrib")$
      (%i2) std_bernoulli(p);
      (%o2)                  std_binomial(1, p)
      (%i3) assume(0<p,p<1)$ std_bernoulli(p);
      (%o4)                  sqrt(1 - p) sqrt(p)

Function: skewness_bernoulli (p)

  Returns the skewness coefficient of a Bernoulli(p) random variable, with 0<p<1.

  The Bernoulli(p) random variable is equivalent to the Binomial(1,p), therefore when Maxima has not enough information to get the result, a noun form based on the binomial skewness coefficient is returned.

      (%i1) load ("distrib")$
      (%i2) skewness_bernoulli(p);
      (%o2)                skewness_binomial(1, p)
      (%i3) assume(0<p,p<1)$ skewness_bernoulli(p);
                                   1 - 2 p
      (%o4)                  -------------------
                             sqrt(1 - p) sqrt(p)

Function: kurtosis_bernoulli (p)

  Returns the kurtosis coefficient of a Bernoulli(p) random variable, with 0<p<1.

  The Bernoulli(p) random variable is equivalent to the Binomial(1,p), therefore when Maxima has not enough information to get the result, a noun form based on the binomial kurtosis coefficient is returned.

      (%i1) load ("distrib")$
      (%i2) kurtosis_bernoulli(p);
      (%o2)                kurtosis_binomial(1, p)
      (%i3) assume(0<p,p<1)$ kurtosis_bernoulli(p);
                               1 - 6 (1 - p) p
      (%o4)                    ---------------
                                  (1 - p) p

Function: random_bernoulli (p)
Function: random_bernoulli (p, n)

  Returns a Bernoulli(p) random variate, with 0<p<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")`.

Function: pdf_geometric (x, p)

  Returns the value at x of the probability function of a Geometric(p) random variable, with 0<p<1. To make use of this function, write first `load("distrib")`.

Function: cdf_geometric (x, p)

  Returns the value at x of the distribution function of a Geometric(p) random variable, with 0<p<1. To make use of this function, write first `load("distrib")`.

Function: quantile_geometric (q, p)

  Returns the q-quantile of a Geometric(p) random variable, with 0<p<1; in other words, this is the inverse of `cdf_geometric`. Argument q must be an element of [0,1]. To make use of this function, write first `load("distrib")`.

Function: mean_geometric (p)

  Returns the mean of a Geometric(p) random variable, with 0<p<1. To make use of this function, write first `load("distrib")`.

Function: var_geometric (p)

  Returns the variance of a Geometric(p) random variable, with 0<p<1. To make use of this function, write first `load("distrib")`.

Function: std_geometric (p)

  Returns the standard deviation of a Geometric(p) random variable, with 0<p<1. To make use of this function, write first `load("distrib")`.

Function: skewness_geometric (p)

  Returns the skewness coefficient of a Geometric(p) random variable, with 0<p<1. To make use of this function, write first `load("distrib")`.

Function: kurtosis_geometric (p)

  Returns the kurtosis coefficient of a geometric random variable Geo(p), with 0<p<1. To make use of this function, write first `load("distrib")`.

Function: random_geometric (p)
Function: random_geometric (p, n)

  Returns a Geometric(p) random variate, with 0<p<1. Calling `random_geometric` with a second argument n, a random sample of size n will be simulated.

  The algorithm is based on simulation of Bernoulli trials.

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

Function: pdf_discrete_uniform (x, n)

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

Function: cdf_discrete_uniform (x, n)

  Returns the value at x of the distribution function of a Discrete Uniform(n) random variable, with n a strictly positive integer. To make use of this function, write first `load("distrib")`.

Function: quantile_discrete_uniform (q, n)

  Returns the q-quantile of a Discrete Uniform(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")`.

Function: mean_discrete_uniform (n)

  Returns the mean of a Discrete Uniform(n) random variable, with n a strictly positive integer. To make use of this function, write first `load("distrib")`.

Function: var_discrete_uniform (n)

  Returns the variance of a Discrete Uniform(n) random variable, with n a strictly positive integer. To make use of this function, write first `load("distrib")`.

Function: std_discrete_uniform (n)

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

Function: skewness_discrete_uniform (n)

  Returns the skewness coefficient of a Discrete Uniform(n) random variable, with n a strictly positive integer. To make use of this function, write first `load("distrib")`.

Function: kurtosis_discrete_uniform (n)

  Returns the kurtosis coefficient of a Discrete Uniform(n) random variable, with n a strictly positive integer. To make use of this function, write first `load("distrib")`.

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

  Returns a Discrete Uniform(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")`.

Function: pdf_hypergeometric (x, n1, n2, n)

  Returns the value at x of the probability function of a Hypergeometric(n1,n2,n) random variable, with n1, n2 and n non negative integers and n<=n1+n2. Being n1 the number of objects of class A, n2 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")`.

Function: cdf_hypergeometric (x, n1, n2, n)

  Returns the value at x of the distribution function of a Hypergeometric(n1,n2,n) random variable, with n1, n2 and n non negative integers and n<=n1+n2. See `pdf_hypergeometric` for a more complete description.

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

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

  Returns the q-quantile of a Hypergeometric(n1,n2,n) random variable, with n1, n2 and n non negative integers and n<=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")`.

Function: mean_hypergeometric (n1, n2, n)

  Returns the mean of a discrete uniform random variable Hyp(n1,n2,n), with n1, n2 and n non negative integers and n<=n1+n2. To make use of this function, write first `load("distrib")`.

Function: var_hypergeometric (n1, n2, n)

  Returns the variance of a hypergeometric random variable Hyp(n1,n2,n), with n1, n2 and n non negative integers and n<=n1+n2. To make use of this function, write first `load("distrib")`.

Function: std_hypergeometric (n1, n2, n)

  Returns the standard deviation of a Hypergeometric(n1,n2,n) random variable, with n1, n2 and n non negative integers and n<=n1+n2. To make use of this function, write first `load("distrib")`.

Function: skewness_hypergeometric (n1, n2, n)

  Returns the skewness coefficient of a Hypergeometric(n1,n2,n) random variable, with n1, n2 and n non negative integers and n<=n1+n2. To make use of this function, write first `load("distrib")`.

Function: kurtosis_hypergeometric (n1, n2, n)

  Returns the kurtosis coefficient of a Hypergeometric(n1,n2,n) random variable, with n1, n2 and n non negative integers and n<=n1+n2. To make use of this function, write first `load("distrib")`.

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

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

  Algorithm described in Kachitvichyanukul, V., Schmeiser, B.W. (1985) Computer generation of hypergeometric random variates. Journal of Statistical Computation and Simulation 22, 127-145.

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

Function: pdf_negative_binomial (x, n, p)

  Returns the value at x of the probability function of a Negative Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: cdf_negative_binomial (x, n, p)

  Returns the value at x of the distribution function of a Negative Binomial(n,p) random variable, with 0<p<1 and n a positive integer.

      (%i1) load ("distrib")$
      (%i2) cdf_negative_binomial(3,4,1/8);
                                  3271
      (%o2)                      ------
                                 524288
      (%i3) float(%);
      (%o3)              .006238937377929687

Function: quantile_negative_binomial (q, n, p)

  Returns the q-quantile of a Negative Binomial(n,p) random variable, with 0<p<1 and n a positive integer; 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")`.

Function: mean_negative_binomial (n, p)

  Returns the mean of a Negative Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: var_negative_binomial (n, p)

  Returns the variance of a Negative Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: std_negative_binomial (n, p)

  Returns the standard deviation of a Negative Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: skewness_negative_binomial (n, p)

  Returns the skewness coefficient of a Negative Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

Function: kurtosis_negative_binomial (n, p)

  Returns the kurtosis coefficient of a Negative Binomial(n,p) random variable, with 0<p<1 and n a positive integer. To make use of this function, write first `load("distrib")`.

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

  Returns a Negative Binomial(n,p) random variate, with 0<p<1 and n a positive integer. 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")`.

Previous: Functions and Variables for continuous distributions, Nach oben: Package distrib [Inhalt][Index]