1 @c -*- mode: texinfo -*-
3 * Introduction to distrib::
4 * Functions and Variables for continuous distributions::
5 * Functions and Variables for discrete distributions::
8 @c Define an m4 macro for the NormalRV function that is used below.
9 @c Can't use @macro because m4 is processed too late for this to work.
10 m4_define(<<<m4_Normal_RV>>>,
11 m4_math(<<<{\it Normal}($1, $2)>>>, <<<Normal($1, $2)>>>))
13 @c Define the function student t to denote Student's t random variable
14 m4_define(<<<m4_Student_T_RV>>>,
17 @c Define noncentral Student's t RV
18 m4_define(<<<m4_Noncentral_T_RV>>>,
19 m4_math(<<<{\it nc\_t}($1, $2)>>>,<<<nc_t($1, $2)>>>))
21 @c Define Chi^2(n), the chi-squared random variate function.
22 m4_define(<<<m4_Chi2_RV>>>,
23 m4_math(<<<\chi^2($1)>>>, <<<Chi^2($2)>>>))
25 @c Define the Gamma RV
26 m4_define(<<<m4_Gamma_RV>>>,
27 m4_math(<<<\Gamma\left($1,$2\right)>>>, <<<Gamma($1,$2)>>>))
29 @c Define the noncentral chi-squared RV
30 m4_define(<<<m4_noncentral_chi2_RV>>>,
31 m4_math(<<<{\it nc\_Chi}^2($1,$2)>>>, <<<nc_Chi^2($1,$2)>>>))
33 @c Define the exponential RV
34 m4_define(<<<m4_Exponential_RV>>>,
35 m4_math(<<<{\it Exponential}($1)>>>, <<<Exponential($1)>>>))
37 @c Define the Weibull RV
38 m4_define(<<<m4_Weibull_RV>>>,
39 m4_math(<<<{\it Weibull}($1,$2)>>>, <<<Weibull($1,$2)>>>))
41 @c Define lognormal RV
42 m4_define(<<<m4_Lognormal_RV>>>,
43 m4_math(<<<{\it Lognormal}($1,$2)>>>,<<<Lognormal($1,$2)>>>))
46 m4_define(<<<m4_Beta_RV>>>,
47 m4_math(<<<{\it Beta}($1,$2)>>>,<<<Beta($1,$2)>>>))
49 @c Define continuous uniform RV
50 m4_define(<<<m4_Continuous_Uniform_RV>>>,
52 ContinuousUniform}($1,$2)>>>,<<<ContinuousUniform($1,$2)>>>))
55 m4_define(<<<m4_Logistic_RV>>>,
56 m4_math(<<<{\it Logistic}($1,$2)>>>,<<<<Logistice($1,$2)>>>))
59 m4_define(<<<m4_Pareto_RV>>>,
60 m4_math(<<<{\it Pareto}($1,$2)>>>,<<<Pareto($1,$2)>>>))
63 m4_define(<<<m4_Rayleigh_RV>>>,
64 m4_math(<<<{\it Rayleigh}($1)>>>,<<<Rayleigh($1)>>>))
67 m4_define(<<<m4_Laplace_RV>>>,
68 m4_math(<<<{\it Laplace}($1,$2)>>>,<<<Laplace($1,$2)>>>))
71 m4_define(<<<m4_Cauchy_RV>>>,
72 m4_math(<<<{\it Cauchy}($1,$2)>>>,<<<Cauchy($1,$2)>>>))
75 m4_define(<<<m4_Gumbel_RV>>>,
76 m4_math(<<<{\it Gumbel}($1,$2)>>>,<<<Gumbel($1,$2)>>>))
79 m4_define(<<<m4_Binomial_RV>>>,
80 m4_math(<<<{\it Binomial}($1,$2)>>>,<<<Binomial($1,$2)>>>))
83 m4_define(<<<m4_Poisson_RV>>>,
84 m4_math(<<<{\it Poisson}($1)>>>,<<<Poisson($1)>>>))
86 @c Define Bernoulli RV
87 m4_define(<<<m4_Bernoulli_RV>>>,
88 m4_math(<<<{\it Bernoulli}($1)>>>,<<<Bernoulli($1)>>>))
90 @c Define Geometric RV
91 m4_define(<<<m4_Geometric_RV>>>,
92 m4_math(<<<{\it Geometric}($1)>>>,<<<Geometric($1)>>>))
94 @c Define Discrete Uniform RV
95 m4_define(<<<m4_DiscreteUniform_RV>>>,
96 m4_math(<<<{\it DiscreteUniform}($1)>>>,<<<DiscreteUniform($1)>>>))
98 @c Define Hypergeometric RV
99 m4_define(<<<m4_Hypergeometric_RV>>>,
100 m4_math(<<<{\it Hypergeometric}($1,$2,$3)>>>,<<<Hypergeometric($1,$2,$3)>>>))
102 @c Define Negative Binomial RV
103 m4_define(<<<m4_NegativeBinomial_RV>>>,
104 m4_math(<<<{\it NegativeBinomial}($1,$2)>>>,<<<NegativeBinomial($1,$2)>>>))
107 @node Introduction to distrib, Functions and Variables for continuous distributions
108 @section Introduction to distrib
111 Package @code{distrib} contains a set of functions for making probability computations on both discrete and continuous univariate models.
113 What follows is a short reminder of basic probabilistic related definitions.
115 Let @math{f(x)} be the @var{density function} of an absolute continuous random variable @math{X}. The @var{distribution function} is defined as
117 <<<F\left(x\right)=\int_{ -\infty }^{x}{f\left(u\right)\;du}>>>,
129 which equals the probability m4_math(<<<{\rm Pr}(X \le x)>>>, <<<Pr(X <= x)>>>).
131 The @var{mean} value is a localization parameter and is defined as
133 <<<E\left[X\right]=\int_{ -\infty }^{\infty }{x\,f\left(x\right)\;dx}>>>,
146 The @var{variance} is a measure of variation,
148 <<<V\left[X\right]=\int_{ -\infty }^{\infty }{f\left(x\right)\,\left(x
149 -E\left[X\right]\right)^2\;dx}>>>,
155 V[X] = I f(x) (x - E[X]) dx
161 which is a positive real number. The square root of the variance is
162 the @var{standard deviation}, m4_math(<<<D[x]=\sqrt{V[X]}>>>, <<<D[X]=sqrt(V[X])>>>), and it is another measure of variation.
164 The @var{skewness coefficient} is a measure of non-symmetry,
166 <<<SK\left[X\right]={{\int_{ -\infty }^{\infty }{f\left(x\right)\,
167 \left(x-E\left[X\right]\right)^3\;dx}}\over{D\left[X\right]^3}}>>>,
173 SK[X] = ----- I f(x) (x - E[X]) dx
180 And the @var{kurtosis coefficient} measures the peakedness of the distribution,
182 <<<KU\left[X\right]={{\int_{ -\infty }^{\infty }{f\left(x\right)\,
183 \left(x-E\left[X\right]\right)^4\;dx}}\over{D\left[X\right]^4}}-3>>>,
189 KU[X] = ----- I f(x) (x - E[X]) dx - 3
195 If @math{X} is gaussian, @math{KU[X]=0}. In fact, both skewness and kurtosis are shape parameters used to measure the non--gaussianity of a distribution.
197 If the random variable @math{X} is discrete, the density, or @var{probability}, function @math{f(x)} takes positive values within certain countable set of numbers @math{x_i}, and zero elsewhere. In this case, the distribution function is
199 <<< F\left(x\right)=\sum_{x_{i}\leq x}{f\left(x_{i}\right)} >>>,
212 The mean, variance, standard deviation, skewness coefficient and kurtosis coefficient take the form
215 E\left[X\right]&=\sum_{x_{i}}{x_{i}f\left(x_{i}\right)}, \cr
216 V\left[X\right]&=\sum_{x_{i}}{f\left(x_{i}\right)\left(x_{i}-E\left[X\right]\right)^2},\cr
217 D\left[X\right]&=\sqrt{V\left[X\right]},\cr
218 SK\left[X\right]&={{\sum_{x_{i}}{f\left(x\right)\,
219 \left(x-E\left[X\right]\right)^3\;dx}}\over{D\left[X\right]^3}}, \cr
220 KU\left[X\right]&={{\sum_{x_{i}}{f\left(x\right)\,
221 \left(x-E\left[X\right]\right)^4\;dx}}\over{D\left[X\right]^4}}-3,
235 V[X] = > f(x ) (x - E[X]) ,
245 SK[X] = ------- > f(x ) (x - E[X])
253 KU[X] = ------- > f(x ) (x - E[X]) - 3 ,
262 There is a naming convention in package @code{distrib}. Every function name has two parts, the first one makes reference to the function or parameter we want to calculate,
265 Density function (pdf_*)
266 Distribution function (cdf_*)
267 Quantile (quantile_*)
270 Standard deviation (std_*)
271 Skewness coefficient (skewness_*)
272 Kurtosis coefficient (kurtosis_*)
273 Random variate (random_*)
276 The second part is an explicit reference to the probabilistic model,
278 Continuous distributions:
282 Noncentral Chi^2 (*noncentral_chi2)
285 Lognormal (*lognormal)
288 Continuous uniform (*continuous_uniform)
297 Discrete distributions:
300 Bernoulli (*bernoulli)
301 Geometric (*geometric)
302 Discrete uniform (*discrete_uniform)
303 hypergeometric (*hypergeometric)
304 Negative binomial (*negative_binomial)
305 Finite discrete (*general_finite_discrete)
308 For example, @code{pdf_student_t(x,n)} is the density function of the Student distribution with @var{n} degrees of freedom, @code{std_pareto(a,b)} is the standard deviation of the Pareto distribution with parameters @var{a} and @var{b} and @code{kurtosis_poisson(m)} is the kurtosis coefficient of the Poisson distribution with mean @var{m}.
311 In order to make use of package @code{distrib} you need first to load it by typing
313 (%i1) load("distrib")$
316 For comments, bugs or suggestions, please contact the author at @var{'riotorto AT yahoo DOT com'}.
318 @opencatbox{Categories:}
319 @category{Statistical functions}
320 @category{Share packages}
321 @category{Package distrib}
327 @node Functions and Variables for continuous distributions, Functions and Variables for discrete distributions, Introduction to distrib
328 @section Functions and Variables for continuous distributions
329 Maxima knows the following kinds of continuous distributions.
332 * Normal Random Variable::
333 * Student's t Random Variable::
334 * Noncentral Student's t Random Variable::
335 * Chi-squared Random Variable::
336 * Noncentral Chi-squared Random Variable::
337 * F Random Variable::
338 * Exponential Random Variable::
339 * Lognormal Random Variable::
340 * Gamma Random Variable::
341 * Beta Random Variable::
342 * Continuous Uniform Random Variable::
343 * Logistic Random Variable::
344 * Pareto Random Variable::
345 * Weibull Random Variable::
346 * Rayleigh Random Variable::
347 * Laplace Random Variable::
348 * Cauchy Random Variable::
349 * Gumbel Random Variable::
352 @node Normal Random Variable, Student's t Random Variable, Functions and Variables for continuous distributions, Functions and Variables for continuous distributions
353 @subsection Normal Random Variable
355 Normal random variables (also called Gaussian) is denoted
356 by m4_Normal_RV(m, s) where
357 @math{m} is the mean and @math{s > 0} is the standard deviation.
360 @deffn {Function} pdf_normal (@var{x},@var{m},@var{s})
361 Returns the value at @var{x} of the density function of a m4_Normal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
365 <<<f(x; m, s) = {1\over s\sqrt{2\pi}} e^{\displaystyle -{(x-m)^2\over 2s^2}}>>>,
374 f(x, m, s) = -------------------
379 @opencatbox{Categories:}
380 @category{Package distrib}
387 @deffn {Function} cdf_normal (@var{x},@var{m},@var{s})
388 Returns the value at @var{x} of the distribution function of a m4_Normal_RV(m,s) random variable, with @math{s>0}. This function is defined in terms of Maxima's built-in error function @code{erf}.
390 The cdf can be written analytically:
392 <<<F(x; m, s) = {1\over 2} + {1\over 2} {\rm erf}\left(x-m\over s\sqrt{2}\right)>>>,
398 F(x, m, s) = -------------- + -
405 @c cdf_normal(x,m,s);
408 (%i1) load ("distrib")$
410 (%i2) cdf_normal(x,m,s);
414 (%o2) -------------- + -
419 See also @mrefdot{erf}
421 @opencatbox{Categories:}
422 @category{Package distrib}
428 @anchor{quantile_normal}
429 @deffn {Function} quantile_normal (@var{q},@var{m},@var{s})
430 Returns the @var{q}-quantile of a m4_Normal_RV(m,s) random variable, with @math{s>0}; in other words, this is the inverse of @mrefdot{cdf_normal} Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
434 @c quantile_normal(95/100,0,1);
438 (%i1) load ("distrib")$
440 (%i2) quantile_normal(95/100,0,1);
442 (%o2) sqrt(2) inverse_erf(--)
447 (%o3) 1.644853626951472
451 @opencatbox{Categories:}
452 @category{Package distrib}
459 @deffn {Function} mean_normal (@var{m},@var{s})
460 Returns the mean of a m4_Normal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
471 @opencatbox{Categories:}
472 @category{Package distrib}
479 @deffn {Function} var_normal (@var{m},@var{s})
480 Returns the variance of a m4_Normal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
492 @opencatbox{Categories:}
493 @category{Package distrib}
499 @deffn {Function} std_normal (@var{m},@var{s})
500 Returns the standard deviation of a m4_Normal_RV(m,s) random variable, with @math{s>0}, namely @var{s}. To make use of this function, write first @code{load("distrib")}.
502 The standard deviation is
511 @opencatbox{Categories:}
512 @category{Package distrib}
518 @anchor{skewness_normal}
519 @deffn {Function} skewness_normal (@var{m},@var{s})
520 Returns the skewness coefficient of a m4_Normal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
522 The skewness coefficient is
530 @opencatbox{Categories:}
531 @category{Package distrib}
537 @anchor{kurtosis_normal}
538 @deffn {Function} kurtosis_normal (@var{m},@var{s})
539 Returns the kurtosis coefficient of a m4_Normal_RV(m,s) random variable, with @math{s>0}, which is always equal to 0. To make use of this function, write first @code{load("distrib")}.
541 The kurtosis coefficient is
551 @opencatbox{Categories:}
552 @category{Package distrib}
558 @anchor{random_normal}
559 @deffn {Function} random_normal (@var{m},@var{s}) @
560 @fname{random_normal} (@var{m},@var{s},@var{n})
562 Returns a m4_Normal_RV(m,s) random variate, with @math{s>0}. Calling @code{random_normal} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
564 This is an implementation of the Box-Mueller algorithm, as described in Knuth, D.E. (1981) @var{Seminumerical Algorithms. The Art of Computer Programming.} Addison-Wesley.
566 To make use of this function, write first @code{load("distrib")}.
568 @opencatbox{Categories:}
569 @category{Package distrib}
570 @category{Random numbers}
575 @node Student's t Random Variable, Noncentral Student's t Random Variable, Normal Random Variable, Functions and Variables for continuous distributions
576 @subsection Student's t Random Variable
579 Student's t random variable is denoted by m4_Student_T_RV(n) where
580 @math{n} is the degrees of freedom with @math{n > 0}. If @math{Z} is
581 a m4_Normal_RV(0,1) variable and @math{V} is an
582 independent m4_math(\chi^2, chi^2) random variable with @math{n} degress of
586 <<<Z \over \sqrt{V/n}>>>,
587 <<<@math{Z/sqrt(V/n)}>>>)
589 has a Student's @math{t}-distribution with @math{n} degrees of freedom.
591 @anchor{pdf_student_t}
592 @deffn {Function} pdf_student_t (@var{x},@var{n})
593 Returns the value at @var{x} of the density function of a Student random variable m4_Student_T_RV(n), with @math{n>0} degrees of freedom. To make use of this function, write first @code{load("distrib")}.
597 <<<f(x; n) = \left[\sqrt{n} B\left({1\over 2}, {n\over 2}\right)\right]^{-1}
598 \left(1+{x^2\over n}\right)^{\displaystyle -{n+1\over 2}}>>>,
604 gamma(-----) (-- + 1)
606 f(x, n) = ------------------------------
608 sqrt(%pi) gamma(-) sqrt(n)
611 @math{(sqrt(n)*beta(1/2,n/2))^(-1) (1+x^2/n)^(-(n+1)/2)}>>>)
613 @opencatbox{Categories:}
614 @category{Package distrib}
620 @anchor{cdf_student_t}
621 @deffn {Function} cdf_student_t (@var{x},@var{n})
622 Returns the value at @var{x} of the distribution function of a Student random variable m4_Student_T_RV(n), with @math{n>0} degrees of freedom.
628 1-\displaystyle{1\over 2} I_t\left({n\over 2}, {1\over 2}\right) & $x \ge 0$ \cr
630 \displaystyle{1\over 2} I_t\left({n\over 2}, {1\over 2}\right) & $x < 0$
634 [ 1-1/2*I_t(n/2, 1/2) x >= 0
636 [ 1/2*I_t(n/2, 1/2) x < 0
640 where m4_math(<<<t = n/(n+x^2)>>>, <<<t = n/(n+x^2)>>>) and m4_math(<<<I_t(a,b)>>>, <<<I_t(a,b)>>>) is the
641 @ref{beta_incomplete_regularized} function.
645 @c cdf_student_t(1/2, 7/3);
649 (%i1) load ("distrib")$
651 (%i2) cdf_student_t(1/2, 7/3);
653 beta_incomplete_regularized(-, -, --)
655 (%o2) 1 - -------------------------------------
660 (%o3) 0.6698450596140415
664 @opencatbox{Categories:}
665 @category{Package distrib}
671 @anchor{quantile_student_t}
672 @deffn {Function} quantile_student_t (@var{q},@var{n})
673 Returns the @var{q}-quantile of a Student random variable m4_Student_T_RV(n), with @math{n>0}; in other words, this is the inverse of @code{cdf_student_t}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
675 @opencatbox{Categories:}
676 @category{Package distrib}
682 @anchor{mean_student_t}
683 @deffn {Function} mean_student_t (@var{n})
684 Returns the mean of a Student random variable m4_Student_T_RV(n), with @math{n>0}. To make use of this function, write first @code{load("distrib")}.
694 @opencatbox{Categories:}
695 @category{Package distrib}
701 @anchor{var_student_t}
702 @deffn {Function} var_student_t (@var{n})
703 Returns the variance of a Student random variable m4_Student_T_RV(n), with @math{n>2}.
707 <<<V[X] = {n\over n-2}>>>,
721 (%i1) load ("distrib")$
723 (%i2) var_student_t(n);
730 @opencatbox{Categories:}
731 @category{Package distrib}
737 @anchor{std_student_t}
738 @deffn {Function} std_student_t (@var{n})
739 Returns the standard deviation of a Student random variable m4_Student_T_RV(n), with @math{n>2}. To make use of this function, write first @code{load("distrib")}.
741 The standard deviation is
743 <<<D[X] = \sqrt{\displaystyle{n\over n-2}}>>>,
753 @opencatbox{Categories:}
754 @category{Package distrib}
760 @anchor{skewness_student_t}
761 @deffn {Function} skewness_student_t (@var{n})
762 Returns the skewness coefficient of a Student random variable m4_Student_T_RV(n), with @math{n>3}, which is always equal to 0. To make use of this function, write first @code{load("distrib")}.
764 The skewness coefficient is
773 @opencatbox{Categories:}
774 @category{Package distrib}
780 @anchor{kurtosis_student_t}
781 @deffn {Function} kurtosis_student_t (@var{n})
782 Returns the kurtosis coefficient of a Student random variable m4_Student_T_RV(n), with @math{n>4}. To make use of this function, write first @code{load("distrib")}.
784 The kurtosis coefficient is
786 <<<KU[X] = {6\over n-4}>>>,
795 @opencatbox{Categories:}
796 @category{Package distrib}
802 @anchor{random_student_t}
803 @deffn {Function} random_student_t (@var{n}) @
804 @fname{random_student_t} (@var{n},@var{m})
806 Returns a Student random variate m4_Student_T_RV(n), with @math{n>0}. Calling @code{random_student_t} with a second argument @var{m}, a random sample of size @var{m} will be simulated.
808 The implemented algorithm is based on the fact that if @math{Z} is a
809 normal random variable m4_Normal_RV(0,1) and @math{S^2} is
810 a m4_math(\chi^2, chi squared) random variable with @math{n} degrees of
811 freedom, m4_Chi2_RV(n), then
814 <<<X={{Z}\over{\sqrt{{S^2}\over{n}}}}>>>,
825 is a Student random variable with @math{n} degrees of freedom, m4_Student_T_RV(n).
827 To make use of this function, write first @code{load("distrib")}.
829 @opencatbox{Categories:}
830 @category{Package distrib}
831 @category{Random numbers}
836 @node Noncentral Student's t Random Variable, Chi-squared Random Variable, Student's t Random Variable, Functions and Variables for continuous distributions
837 @subsection Noncentral Student's t Random Variable
839 Let @math{ncp} be the non-centrality parameter, @math{n} be the
840 degrees of freedom for the non-central Student's @math{t} random
843 Then let @math{X} be a m4_Normal_RV(n,ncp) and @math{S^2} be an independent m4_math(\chi^2,
844 chi squared) random variable with @math{n} degrees of freedom, the
847 <<<U = {X \over \sqrt{S^2\over n}}>>>,
848 <<<@math{U = X/sqrt(S^2/n)}>>>)
850 has a non-central Student's @math{t} distribution with non-centrality
851 parameter @math{ncp}.
853 @anchor{pdf_noncentral_student_t}
854 @deffn {Function} pdf_noncentral_student_t (@var{x},@var{n},@var{ncp})
855 Returns the value at @var{x} of the density function of a noncentral Student random variable m4_Noncentral_T_RV(n,ncp), with @math{n>0} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
859 <<<f(x; n, \mu) = \left[\sqrt{n} B\left({1\over 2}, {n\over
860 2}\right)\right]^{-1}\left(1+{x^2\over n}\right)^{-{(n+1)/2}}
862 \bigg[A_n(x; \mu) + B_n(x; \mu)\bigg]>>>,
869 %e (x + 1) (B(x, n, mu) + An(x, n, mu))
870 f(x;n,mu) = -------------------------------------------------
880 A_n(x;\mu) &= {}_1F_1\left({n+1\over 2}; {1\over 2}; {\mu^2 x^2\over
881 2\left(x^2+n\right)}\right) \cr
882 B_n(x;\mu) &= {\sqrt{2}\mu x \over \sqrt{x^2+n}} {\Gamma\left({n\over
883 2} + 1\right)\over \Gamma\left({n+1\over 2}\right)}\;
884 {}_1F_1\left({n\over 2} + 1; {3\over 2}; {\mu^2 x^2\over
885 2\left(x^2+n\right)}\right)
891 A(x, n, mu) = %f ([-----], [-], ----------)
897 sqrt(2) mu %f ([- + 1], [-], ----------) gamma(- + 1) x
900 B(x, n, mu) = ----------------------------------------------------------
902 gamma(-----) sqrt(x + n)
906 and m4_math(\mu, mu) is the non-centrality parameter @math{ncp}.
908 Sometimes an extra work is necessary to get the final result.
912 @c expand(pdf_noncentral_student_t(3,5,0.1));
916 (%i1) load ("distrib")$
918 (%i2) expand(pdf_noncentral_student_t(3,5,0.1));
919 rat: replaced 0.01889822365046136 by 15934951/843198350 = 0.01889822365046136
921 rat: replaced -8.734356480209641 by -294697965/33740089 = -8.734356480209641
923 rat: replaced 4.136255165816327 by 51033443/12338079 = 4.136255165816332
925 rat: replaced 1.08061432164203 by 56754827/52520891 = 1.08061432164203
927 rat: replaced 0.0565127306411839 by 5608717/99246965 = 0.05651273064118384
929 rat: replaced -300.8069396896258 by -79782423/265228 = -300.8069396896256
931 rat: replaced 160.6269176184973 by 178374907/1110492 = 160.626917618497
933 0.04296414417400905 5 1.323650307289301e-6 5
934 (%o2) ------------------------ + -------------------------
938 1.94793720435093e-4 5
939 + ------------------------
944 (%o3) 0.02080593159405671
948 @opencatbox{Categories:}
949 @category{Package distrib}
955 @anchor{cdf_noncentral_student_t}
956 @deffn {Function} cdf_noncentral_student_t (@var{x},@var{n},@var{ncp})
957 Returns the value at @var{x} of the distribution function of a noncentral Student random variable m4_Noncentral_T_RV(n,ncp), with @math{n>0} degrees of freedom and noncentrality parameter @math{ncp}. This function has no closed form and it is numerically computed.
961 @c cdf_noncentral_student_t(-2,5,-5);
964 (%i1) load ("distrib")$
966 (%i2) cdf_noncentral_student_t(-2,5,-5);
967 (%o2) 0.995203009331975
971 @opencatbox{Categories:}
972 @category{Package distrib}
978 @anchor{quantile_noncentral_student_t}
979 @deffn {Function} quantile_noncentral_student_t (@var{q},@var{n},@var{ncp})
980 Returns the @var{q}-quantile of a noncentral Student random variable m4_Noncentral_T_RV(n,ncp), with @math{n>0} degrees of freedom and noncentrality parameter @math{ncp}; in other words, this is the inverse of @code{cdf_noncentral_student_t}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
982 @opencatbox{Categories:}
983 @category{Package distrib}
989 @anchor{mean_noncentral_student_t}
990 @deffn {Function} mean_noncentral_student_t (@var{n},@var{ncp})
991 Returns the mean of a noncentral Student random variable m4_Noncentral_T_RV(n,ncp), with @math{n>1} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
995 <<<E[X] = {\mu \sqrt{n}\; \Gamma\left(\displaystyle{n-1\over 2}\right) \over
996 \sqrt{2}\;\Gamma\left(\displaystyle{n\over 2}\right)}>>>,
1000 mu gamma(-----) sqrt(n)
1002 E[X] = -----------------------
1009 where m4_math(\mu, mu) is the noncentrality parameter @math{ncp}.
1012 @c load ("distrib")$
1013 @c mean_noncentral_student_t(df,k);
1016 (%i1) load ("distrib")$
1018 (%i2) mean_noncentral_student_t(df,k);
1020 gamma(------) sqrt(df) k
1022 (%o2) ------------------------
1029 @opencatbox{Categories:}
1030 @category{Package distrib}
1036 @anchor{var_noncentral_student_t}
1037 @deffn {Function} var_noncentral_student_t (@var{n},@var{ncp})
1038 Returns the variance of a noncentral Student random variable m4_Noncentral_T_RV(n,ncp), with @math{n>2} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1042 <<<V[X] = {n(\mu^2+1)\over n-2} - {n\mu^2\; \Gamma\left(\displaystyle{n-1\over 2}\right)^2
1043 \over 2\Gamma\left(\displaystyle{n\over 2}\right)^2}>>>,
1047 2 gamma (-----) n ncp
1049 V[X] = ------------ - --------------------
1056 where m4_math(\mu, mu) is the noncentrality parameter @math{ncp}.
1058 @opencatbox{Categories:}
1059 @category{Package distrib}
1065 @anchor{std_noncentral_student_t}
1066 @deffn {Function} std_noncentral_student_t (@var{n},@var{ncp})
1067 Returns the standard deviation of a noncentral Student random variable m4_Noncentral_T_RV(n,ncp), with @math{n>2} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1069 The standard deviation is
1071 <<<D[X] = \sqrt{{n(\mu^2+1)\over n-2} - {n\mu^2\; \Gamma\left(\displaystyle{n-1\over 2}\right)^2
1072 \over 2\Gamma\left(\displaystyle{n\over 2}\right)^2}}>>>,
1076 2 gamma (-----) n ncp
1078 D[X] = sqrt(------------ - --------------------)
1086 @opencatbox{Categories:}
1087 @category{Package distrib}
1093 @anchor{skewness_noncentral_student_t}
1094 @deffn {Function} skewness_noncentral_student_t (@var{n},@var{ncp})
1095 Returns the skewness coefficient of a noncentral Student random variable m4_Noncentral_T_RV(n,ncp), with @math{n>3} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1097 @c The TeX form is obtained from
1098 @c tex(skewness_noncentral_student_t(n,mu)). Likewise the info form
1099 @c is just cut-n-pasted from maxima's terminal output.
1100 If @math{U} is a non-central Student's @math{t} random variable with
1101 @math{n} degrees of freedom and a noncentrality parameter m4_math(\mu,
1102 mu), the skewness is
1106 {\mu\sqrt{n}\,\Gamma\left({{n-1}\over{2}}\right)
1107 \over{\sqrt{2}\Gamma\left({{n
1108 }\over{2}}\right)\sigma^{3}}}\left({{n
1109 \left(2n+\mu^2-3\right)}\over{\left(n-3\right)\left(n-2\right)}}
1110 -2\sigma^2\right) \cr
1111 \sigma^2 &= {{n\left(\mu^2+1\right)}\over{n-2}}-{{n \mu^2\,
1112 \Gamma\left({{n-1}\over{2}}\right)^2}\over{2\Gamma\left({{n
1113 }\over{2}}\right)^2}}
1120 n - 1 n (2 n + mu - 3)
1121 (mu gamma(-----) sqrt(n) (-----------------
1124 2 mu gamma (-----) n
1126 - 2 (----------- - -------------------)))
1131 2 mu gamma (-----) n
1133 /(sqrt(2) gamma(-) (----------- - -------------------) )
1140 @opencatbox{Categories:}
1141 @category{Package distrib}
1147 @anchor{kurtosis_noncentral_student_t}
1148 @deffn {Function} kurtosis_noncentral_student_t (@var{n},@var{ncp})
1149 Returns the kurtosis coefficient of a noncentral Student random variable m4_Noncentral_T_RV(n,ncp), with @math{n>4} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1151 If @math{U} is a non-central Student's @math{t} random variable with
1152 @math{n} degrees of freedom and a noncentrality parameter m4_math(\mu,
1153 mu), the kurtosis is
1155 @c The formula we see can be basically derived by computing
1156 @c (kurtosis_noncentral_student_t(n,mu)+3)*var_noncentral_student_t(n,mu)^2,
1157 @c which comes from the definition of kurtosis. The rest is then
1158 @c obtained by replacing a constant by F.
1162 {\mu_4\over \sigma^4} - 3\cr
1163 \mu_4 &= {{\left(\mu^4+6\mu^2+3\right)n^2}\over{(n-4)(n-2)}}
1164 -\left({{n\left(3(3n-5)+\mu^2(n+1)\right)
1165 }\over{(n-3)(n-2)}}-3\sigma^2\right) F \cr
1166 \sigma^2 &= {{n\left(\mu^2+1\right)}\over{n-2}}-{{n \mu^2
1167 \Gamma\left({{n-1}\over{2}}\right)^2}\over{2\Gamma\left({{n
1168 }\over{2}}\right)^2}} \cr
1169 F &= {n\mu^2\Gamma\left({n-1\over 2}\right)^2 \over
1170 2\sigma^4\Gamma\left({n\over 2}\right)^2}
1176 (mu + 6 mu + 3) n 2 2 n - 1
1177 (-------------------- - (mu gamma (-----) n
1180 2 2 mu gamma (-----) n
1181 n (3 (3 n - 5) + mu (n + 1)) (mu + 1) n 2
1182 (----------------------------- - 3 (----------- - -------------------)))
1183 (n - 3) (n - 2) n - 2 2 n
1187 2 mu gamma (-----) n
1189 /(2 gamma (-)))/(----------- - -------------------) - 3
1196 @opencatbox{Categories:}
1197 @category{Package distrib}
1203 @anchor{random_noncentral_student_t}
1204 @deffn {Function} random_noncentral_student_t (@var{n},@var{ncp}) @
1205 @fname{random_noncentral_student_t} (@var{n},@var{ncp},@var{m})
1207 Returns a noncentral Student random variate m4_Noncentral_T_RV(n,ncp), with @math{n>0}. Calling @code{random_noncentral_student_t} with a third argument @var{m}, a random sample of size @var{m} will be simulated.
1209 The implemented algorithm is based on the fact that if @var{X} is a
1210 normal random variable m4_Normal_RV(ncp,1) and @math{S^2} is
1211 a m4_math(\chi^2, chi square) random variable with @var{n} degrees of freedom, m4_Chi2_RV(n), then
1213 <<<U={{X}\over{\sqrt{{S^2}\over{n}}}}>>>,
1224 is a noncentral Student random variable with @math{n} degrees of freedom and noncentrality parameter @math{ncp}, m4_Noncentral_T_RV(n,ncp).
1226 To make use of this function, write first @code{load("distrib")}.
1228 @opencatbox{Categories:}
1229 @category{Package distrib}
1230 @category{Random numbers}
1236 @node Chi-squared Random Variable, Noncentral Chi-squared Random Variable, Noncentral Student's t Random Variable, Functions and Variables for continuous distributions
1237 @subsection Chi-squared Random Variable
1239 Let m4_math(<<<X_1, X_2, \ldots, X_n>>>, <<<X_1, X_2, ...,
1240 X_k>>>) be independent and identically distributed m4_Normal_RV(0,1) variables. Then
1242 <<<X^2 = \sum_{i=1}^n X_i^2>>>,
1243 <<<@math{X^2 = sum(X_i^2, i, 1, n)}>>>)
1245 is said to follow a chi-square distribution with @math{n} degrees of
1249 @deffn {Function} pdf_chi2 (@var{x},@var{n})
1250 Returns the value at @var{x} of the density function of a Chi-square random variable m4_Chi2_RV(n), with @math{n>0}.
1251 The m4_Chi2_RV(n) random variable is equivalent to the m4_Gamma_RV(n/2,2).
1258 \displaystyle{x^{n/2-1} e^{-x/2} \over 2^{n/2}
1259 \Gamma\left(\displaystyle{n\over 2}\right)} & for $x
1268 [ ----------------------------- for x >= 0
1270 f(x, n) = [ gamma(-) 2
1278 @c load ("distrib")$
1282 (%i1) load ("distrib")$
1284 (%i2) pdf_chi2(x,n);
1287 (%o2) -----------------------------
1294 @opencatbox{Categories:}
1295 @category{Package distrib}
1302 @deffn {Function} cdf_chi2 (@var{x},@var{n})
1303 Returns the value at @math{x} of the distribution function of a Chi-square random variable m4_Chi2_RV(n), with @math{n>0}.
1309 1 - Q\left(\displaystyle{n\over 2}, {x\over 2}\right) & $x > 0$ \cr
1315 [ (1 - Q(-, -)) for x >= 0
1321 where @math{Q(a,z)} is the @ref{gamma_incomplete_regularized} function.
1324 @c load ("distrib")$
1329 (%i1) load ("distrib")$
1331 (%i2) cdf_chi2(3,4);
1333 (%o2) 1 - gamma_incomplete_regularized(2, -)
1338 (%o3) 0.4421745996289252
1342 @opencatbox{Categories:}
1343 @category{Package distrib}
1349 @anchor{quantile_chi2}
1350 @deffn {Function} quantile_chi2 (@var{q},@var{n})
1351 Returns the @var{q}-quantile of a Chi-square random variable m4_Chi2_RV(n), with @math{n>0}; in other words, this is the inverse of @code{cdf_chi2}. Argument @var{q} must be an element of @math{[0,1]}.
1353 This function has no closed form and it is numerically computed.
1356 @c load ("distrib")$
1357 @c quantile_chi2(0.99,9);
1360 (%i1) load ("distrib")$
1362 (%i2) quantile_chi2(0.99,9);
1363 (%o2) 21.66599433346194
1367 @opencatbox{Categories:}
1368 @category{Package distrib}
1375 @deffn {Function} mean_chi2 (@var{n})
1376 Returns the mean of a Chi-square random variable m4_Chi2_RV(n), with @math{n>0}.
1378 The m4_Chi2_RV(n) random variable is equivalent to the m4_Gamma_RV(n/2,2).
1390 @c load ("distrib")$
1394 (%i1) load ("distrib")$
1401 @opencatbox{Categories:}
1402 @category{Package distrib}
1409 @deffn {Function} var_chi2 (@var{n})
1410 Returns the variance of a Chi-square random variable m4_Chi2_RV(n), with @math{n>0}.
1412 The m4_Chi2_RV(n) random variable is equivalent to the m4_Gamma_RV(n/2,2).
1424 @c load ("distrib")$
1428 (%i1) load ("distrib")$
1435 @opencatbox{Categories:}
1436 @category{Package distrib}
1443 @deffn {Function} std_chi2 (@var{n})
1444 Returns the standard deviation of a Chi-square random variable m4_Chi2_RV(n), with @math{n>0}.
1446 The m4_Chi2_RV(n) random variable is equivalent to the m4_Gamma_RV(n/2,2).
1448 The standard deviation is
1450 <<<D[X] = \sqrt{2n}>>>,
1453 D[X] = sqrt(2) sqrt(n)
1458 @c load ("distrib")$
1462 (%i1) load ("distrib")$
1465 (%o2) sqrt(2) sqrt(n)
1469 @opencatbox{Categories:}
1470 @category{Package distrib}
1476 @anchor{skewness_chi2}
1477 @deffn {Function} skewness_chi2 (@var{n})
1478 Returns the skewness coefficient of a Chi-square random variable m4_Chi2_RV(n), with @math{n>0}.
1480 The m4_Chi2_RV(n) random variable is equivalent to the m4_Gamma_RV(n/2,2).
1482 The skewness coefficient is
1484 <<<SK[X] = \sqrt{8\over n}>>>,
1495 @c load ("distrib")$
1496 @c skewness_chi2(n);
1499 (%i1) load ("distrib")$
1501 (%i2) skewness_chi2(n);
1509 @opencatbox{Categories:}
1510 @category{Package distrib}
1516 @anchor{kurtosis_chi2}
1517 @deffn {Function} kurtosis_chi2 (@var{n})
1518 Returns the kurtosis coefficient of a Chi-square random variable m4_Chi2_RV(n), with @math{n>0}.
1520 The m4_Chi2_RV(n) random variable is equivalent to the m4_Gamma_RV(n/2,2).
1522 The kurtosis coefficient is
1524 <<<KU[X] = {12\over n}>>>,
1534 @c load ("distrib")$
1535 @c kurtosis_chi2(n);
1538 (%i1) load ("distrib")$
1540 (%i2) kurtosis_chi2(n);
1547 @opencatbox{Categories:}
1548 @category{Package distrib}
1554 @anchor{random_chi2}
1555 @deffn {Function} random_chi2 (@var{n}) @
1556 @fname{random_chi2} (@var{n},@var{m})
1558 Returns a Chi-square random variate m4_Chi2_RV(n), with @math{n>0}. Calling @code{random_chi2} with a second argument @var{m}, a random sample of size @var{m} will be simulated.
1560 The simulation is based on the Ahrens-Cheng algorithm. See @code{random_gamma} for details.
1562 To make use of this function, write first @code{load("distrib")}.
1564 @opencatbox{Categories:}
1565 @category{Package distrib}
1566 @category{Random numbers}
1572 @node Noncentral Chi-squared Random Variable, F Random Variable, Chi-squared Random Variable, Functions and Variables for continuous distributions
1573 @subsection Noncentral Chi-squared Random Variable
1575 Let m4_math(<<<X_1, X_2, ..., X_n>>>, <<<X[1], X[2], ..., X[n]>>>) be @math{n}
1576 independent normally distributed random variables with
1577 means m4_math(\mu_k, mu[k]) and unit variances. Then the random variable
1580 <<<\sum_{k=1}^n X_k^2>>>,
1581 <<<@math{sum(X[k]^2, k, 1, n)}>>>)
1583 has a noncentral m4_math(\chi^2, chi-squared) distribution. The
1584 number of degrees of freedom is @math{n}, and the noncentrality
1585 parameter is defined by
1588 <<<\sum_{k=1}^n \mu_k^2>>>,
1589 <<<@math{sum(mu[k]^2, k, 1, n)}>>>)
1591 @anchor{pdf_noncentral_chi2}
1592 @deffn {Function} pdf_noncentral_chi2 (@var{x},@var{n},@var{ncp})
1593 Returns the value at @math{x} of the density function of a
1594 noncentral m4_math(\chi^2, Chi-square) random
1595 variable m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}. To
1596 make use of this function, write first @code{load("distrib")}.
1598 For @math{x < 0}, the pdf is 0, and for m4_math(x \ge 0, x >= 0) the pdf is
1600 <<<f(x; n, \lambda) =
1601 {1\over 2}e^{-(x+\lambda)/2} \left(x\over
1602 \lambda\right)^{n/4-1/2}I_{{n\over 2} - 1}\left(\sqrt{n \lambda}\right)
1610 bessel_i(- - 1, sqrt(ncp x)) (---) %e unit_step(x)
1612 ----------------------------------------------------------------------
1617 @opencatbox{Categories:}
1618 @category{Package distrib}
1624 @anchor{cdf_noncentral_chi2}
1625 @deffn {Function} cdf_noncentral_chi2 (@var{x},@var{n},@var{ncp})
1626 Returns the value at @var{x} of the distribution function of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}. To make use of this function, write first @code{load("distrib")}.
1628 @opencatbox{Categories:}
1629 @category{Package distrib}
1635 @anchor{quantile_noncentral_chi2}
1636 @deffn {Function} quantile_noncentral_chi2 (@var{q},@var{n},@var{ncp})
1637 Returns the @var{q}-quantile of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}; in other words, this is the inverse of @code{cdf_noncentral_chi2}. Argument @var{q} must be an element of @math{[0,1]}.
1639 This function has no closed form and it is numerically computed.
1641 @opencatbox{Categories:}
1642 @category{Package distrib}
1648 @anchor{mean_noncentral_chi2}
1649 @deffn {Function} mean_noncentral_chi2 (@var{n},@var{ncp})
1650 Returns the mean of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}.
1654 <<<E[X] = n + \mu>>>,
1661 where m4_math(\mu) is the noncentrality parameter @var{ncp}.
1665 @opencatbox{Categories:}
1666 @category{Package distrib}
1672 @anchor{var_noncentral_chi2}
1673 @deffn {Function} var_noncentral_chi2 (@var{n},@var{ncp})
1674 Returns the variance of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}.
1678 <<<V[X] = 2(n+2\mu)>>>,
1681 V[X] = 2 (2 ncp + n)
1685 where m4_math(\mu) is the noncentrality parameter @var{ncp}.
1688 @opencatbox{Categories:}
1689 @category{Package distrib}
1695 @anchor{std_noncentral_chi2}
1696 @deffn {Function} std_noncentral_chi2 (@var{n},@var{ncp})
1697 Returns the standard deviation of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}.
1699 The standard deviation is
1701 <<<D[X] = \sqrt{2(n+2\mu)}>>>,
1704 D[X] = sqrt(2) sqrt(2 ncp + n)
1708 where m4_math(\mu) is the noncentrality parameter @var{ncp}.
1710 @opencatbox{Categories:}
1711 @category{Package distrib}
1717 @anchor{skewness_noncentral_chi2}
1718 @deffn {Function} skewness_noncentral_chi2 (@var{n},@var{ncp})
1719 Returns the skewness coefficient of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}.
1721 The skewness coefficient is
1723 <<<SK[X] = {2^{3/2}(n+3\mu) \over (n+2\mu)^{3/2}}>>>,
1728 SK[X] = ---------------
1735 where m4_math(\mu) is the noncentrality parameter @var{ncp}.
1739 @opencatbox{Categories:}
1740 @category{Package distrib}
1746 @anchor{kurtosis_noncentral_chi2}
1747 @deffn {Function} kurtosis_noncentral_chi2 (@var{n},@var{ncp})
1748 Returns the kurtosis coefficient of a noncentral Chi-square random variable m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}.
1750 The kurtosis coefficient is
1752 <<<KU[X] = {12(n+4\mu)\over (2+2\mu)^2}>>>,
1756 KU[X] = -------------
1762 where m4_math(\mu) is the noncentrality parameter @var{ncp}.
1765 @opencatbox{Categories:}
1766 @category{Package distrib}
1772 @anchor{random_noncentral_chi2}
1773 @deffn {Function} random_noncentral_chi2 (@var{n},@var{ncp}) @
1774 @fname{random_noncentral_chi2} (@var{n},@var{ncp},@var{m})
1776 Returns a noncentral Chi-square random variate m4_noncentral_chi2(n,ncp), with @math{n>0} and noncentrality parameter @math{ncp>=0}. Calling @code{random_noncentral_chi2} with a third argument @var{m}, a random sample of size @var{m} will be simulated.
1778 To make use of this function, write first @code{load("distrib")}.
1780 @opencatbox{Categories:}
1781 @category{Package distrib}
1782 @category{Random numbers}
1789 @node F Random Variable, Exponential Random Variable, Noncentral Chi-squared Random Variable, Functions and Variables for continuous distributions
1790 @subsection F Random Variable
1792 Let @math{S_1} and @math{S_2} be independent random variables with
1793 a m4_math(\chi^2, chi-squared) distribution with degrees of freedom
1794 @math{n} and @math{m}, respectively. Then
1796 <<<F = {S_1/n \over S_2/m}>>>,
1797 <<<@math{F = (S_1/n)/(S_2/m)}>>>) has an @math{F} distribution with @math{n} and @math{m} degrees of
1801 @deffn {Function} pdf_f (@var{x},@var{m},@var{n})
1802 Returns the value at @var{x} of the density function of a F random variable @math{F(m,n)}, with @math{m,n>0}. To make use of this function, write first @code{load("distrib")}.
1808 B\left(\displaystyle{m\over 2}, \displaystyle{n\over 2}\right)^{-1}
1809 \left(\displaystyle{m\over n}\right)^{m/ 2}
1811 \left(1 + \displaystyle{m\over n}x\right)^{-\left(n+m\right)/2} & $x >
1821 n n/2 n + m n/2 - 1 n x 2
1822 (-) gamma(-----) x (--- + 1) unit_step(x)
1824 ------------------------------------------------------------
1831 @opencatbox{Categories:}
1832 @category{Package distrib}
1839 @deffn {Function} cdf_f (@var{x},@var{m},@var{n})
1840 Returns the value at @var{x} of the distribution function of a F random variable @math{F(m,n)}, with @math{m,n>0}.
1846 1 - I_z\left(\displaystyle{m\over 2}, {n\over 2}\right) & $x > 0$ \cr
1852 F(x, m, n) = (1 - beta_incomplete_regularized(-, -, -------))
1861 <<<z = {n\over mx+n}>>>,
1864 and m4_math(I_z(a,b)) is the @ref{beta_incomplete_regularized}
1868 @c load ("distrib")$
1873 (%i1) load ("distrib")$
1875 (%i2) cdf_f(2,3,9/4);
1877 (%o2) 1 - beta_incomplete_regularized(-, -, --)
1882 (%o3) 0.6675672817900802
1886 @opencatbox{Categories:}
1887 @category{Package distrib}
1894 @deffn {Function} quantile_f (@var{q},@var{m},@var{n})
1895 Returns the @var{q}-quantile of a F random variable @math{F(m,n)}, with @math{m,n>0}; in other words, this is the inverse of @code{cdf_f}. Argument @var{q} must be an element of @math{[0,1]}.
1898 @c load ("distrib")$
1899 @c quantile_f(2/5,sqrt(3),5);
1902 (%i1) load ("distrib")$
1904 (%i2) quantile_f(2/5,sqrt(3),5);
1905 (%o2) 0.5189478385736904
1909 @opencatbox{Categories:}
1910 @category{Package distrib}
1917 @deffn {Function} mean_f (@var{m},@var{n})
1918 Returns the mean of a F random variable @math{F(m,n)}, with @math{m>0, n>2}. To make use of this function, write first @code{load("distrib")}.
1922 <<<E[X] = {n\over n-2}>>>,
1931 @opencatbox{Categories:}
1932 @category{Package distrib}
1939 @deffn {Function} var_f (@var{m},@var{n})
1940 Returns the variance of a F random variable @math{F(m,n)}, with @math{m>0, n>4}. To make use of this function, write first @code{load("distrib")}.
1944 <<<V[X] = {2n^2(n+m-2) \over m(n-4)(n-2)^2}>>>,
1949 V[X] = ------------------
1954 @opencatbox{Categories:}
1955 @category{Package distrib}
1962 @deffn {Function} std_f (@var{m},@var{n})
1963 Returns the standard deviation of a F random variable @math{F(m,n)}, with @math{m>0, n>4}. To make use of this function, write first @code{load("distrib")}.
1965 The standard deviation is
1967 <<<D[X] = {\sqrt{2}\, n \over n-2} \sqrt{n+m-2\over m(n-4)}>>>,
1971 D[X] = sqrt(2) sqrt(-----) sqrt(---------)
1975 @opencatbox{Categories:}
1976 @category{Package distrib}
1983 @deffn {Function} skewness_f (@var{m},@var{n})
1984 Returns the skewness coefficient of a F random variable @math{F(m,n)}, with @math{m>0, n>6}. To make use of this function, write first @code{load("distrib")}.
1986 The skewness coefficient is
1988 <<<SK[X] = {(n+2m-2)\sqrt{8(n-4)} \over (n-6)\sqrt{m(n+m-2)}}>>>,
1992 2 sqrt(n - 4) (n + 2 m - 2)
1993 SK[X] = ------------------------------
1994 (n - 6) sqrt(m (n + m - 2))
1998 @opencatbox{Categories:}
1999 @category{Package distrib}
2006 @deffn {Function} kurtosis_f (@var{m},@var{n})
2007 Returns the kurtosis coefficient of a F random variable @math{F(m,n)}, with @math{m>0, n>8}. To make use of this function, write first @code{load("distrib")}.
2009 The kurtosis coefficient is
2011 <<<KU[X] = 12{m(n+m-2)(5n-22) + (n-4)(n-2)^2 \over m(n-8)(n-6)(n+m-2)}>>>,
2015 12 (m (n + m - 2) (5 n - 22) + (n - 4) (n - 2) )
2016 KU[X] = ------------------------------------------------
2017 m (n - 8) (n - 6) (n + m - 2)
2021 @opencatbox{Categories:}
2022 @category{Package distrib}
2029 @deffn {Function} random_f (@var{m},@var{n}) @
2030 @fname{random_f} (@var{m},@var{n},@var{k})
2032 Returns a F random variate @math{F(m,n)}, with @math{m,n>0}. Calling @code{random_f} with a third argument @var{k}, a random sample of size @var{k} will be simulated.
2034 The simulation algorithm is based on the fact that if @var{X} is a @math{Chi^2(m)} random variable and @math{Y} is a m4_Chi2_RV(n) random variable, then
2036 <<<F={{n X}\over{m Y}}>>>,
2044 is a F random variable with @var{m} and @var{n} degrees of freedom, @math{F(m,n)}.
2046 To make use of this function, write first @code{load("distrib")}.
2048 @opencatbox{Categories:}
2049 @category{Package distrib}
2050 @category{Random numbers}
2056 @node Exponential Random Variable, Lognormal Random Variable, F Random Variable, Functions and Variables for continuous distributions
2057 @subsection Exponential Random Variable
2059 The @emph{exponential distribution} is the probablity distribution of
2060 the time between events in a process where the events occur
2061 continuously and independently at a constant average rate.
2064 @deffn {Function} pdf_exp (@var{x},@var{m})
2065 Returns the value at @var{x} of the density function of an m4_Exponential_RV(m) random variable, with @math{m>0}.
2067 The m4_Exponential_RV(m) random variable is equivalent to the m4_Weibull_RV(1,1/m).
2073 me^{-mx} & for $x \ge 0$ \cr
2078 [ m*exp(-m*x) for x >= 0
2085 @c load ("distrib")$
2089 (%i1) load ("distrib")$
2093 (%o2) m %e unit_step(x)
2097 @opencatbox{Categories:}
2098 @category{Package distrib}
2105 @deffn {Function} cdf_exp (@var{x},@var{m})
2106 Returns the value at @var{x} of the distribution function of an m4_Exponential_RV(m) random variable, with @math{m>0}.
2108 The m4_Exponential_RV(m) random variable is equivalent to the m4_Weibull_RV(1,1/m).
2114 1 - e^{-mx} & $x \ge 0$ \cr
2119 [ 1 - exp(-m*x) for x >= 0
2125 @c load ("distrib")$
2129 (%i1) load ("distrib")$
2133 (%o2) (1 - %e ) unit_step(x)
2137 @opencatbox{Categories:}
2138 @category{Package distrib}
2144 @anchor{quantile_exp}
2145 @deffn {Function} quantile_exp (@var{q},@var{m})
2146 Returns the @var{q}-quantile of an m4_Exponential_RV(m) random variable, with @math{m>0}; in other words, this is the inverse of @code{cdf_exp}. Argument @var{q} must be an element of @math{[0,1]}.
2148 The m4_Exponential_RV(m) random variable is equivalent to the m4_Weibull_RV(1,1/m).
2151 @c load ("distrib")$
2152 @c quantile_exp(0.56,5);
2153 @c quantile_exp(0.56,m);
2156 (%i1) load ("distrib")$
2158 (%i2) quantile_exp(0.56,5);
2159 (%o2) 0.1641961104139661
2162 (%i3) quantile_exp(0.56,m);
2164 (%o3) ------------------
2169 @opencatbox{Categories:}
2170 @category{Package distrib}
2177 @deffn {Function} mean_exp (@var{m})
2178 Returns the mean of an m4_Exponential_RV(m) random variable, with @math{m>0}.
2180 The m4_Exponential_RV(m) random variable is equivalent to the m4_Weibull_RV(1,1/m).
2184 <<<E[X] = {1\over m}>>>,
2194 @c load ("distrib")$
2198 (%i1) load ("distrib")$
2207 @opencatbox{Categories:}
2208 @category{Package distrib}
2215 @deffn {Function} var_exp (@var{m})
2216 Returns the variance of an m4_Exponential_RV(m) random variable, with @math{m>0}.
2218 The m4_Exponential_RV(m) random variable is equivalent to the m4_Weibull_RV(1,1/m).
2222 <<<V[X] = {1\over m^2}>>>,
2233 @c load ("distrib")$
2237 (%i1) load ("distrib")$
2247 @opencatbox{Categories:}
2248 @category{Package distrib}
2255 @deffn {Function} std_exp (@var{m})
2256 Returns the standard deviation of an m4_Exponential_RV(m) random variable, with @math{m>0}.
2258 The m4_Exponential_RV(m) random variable is equivalent to the m4_Weibull_RV(1,1/m).
2260 The standard deviation is
2262 <<<D[X] = {1\over m}>>>,
2272 @c load ("distrib")$
2276 (%i1) load ("distrib")$
2285 @opencatbox{Categories:}
2286 @category{Package distrib}
2292 @anchor{skewness_exp}
2293 @deffn {Function} skewness_exp (@var{m})
2294 Returns the skewness coefficient of an m4_Exponential_RV(m) random variable, with @math{m>0}.
2296 The m4_Exponential_RV(m) random variable is equivalent to the m4_Weibull_RV(1,1/m).
2298 The skewness coefficient is
2308 @c load ("distrib")$
2312 (%i1) load ("distrib")$
2314 (%i2) skewness_exp(m);
2319 @opencatbox{Categories:}
2320 @category{Package distrib}
2326 @anchor{kurtosis_exp}
2327 @deffn {Function} kurtosis_exp (@var{m})
2328 Returns the kurtosis coefficient of an m4_Exponential_RV(m) random variable, with @math{m>0}.
2330 The m4_Exponential_RV(m) random variable is equivalent to the m4_Weibull_RV(1,1/m).
2332 The kurtosis coefficient is
2342 @c load ("distrib")$
2346 (%i1) load ("distrib")$
2348 (%i2) kurtosis_exp(m);
2353 @opencatbox{Categories:}
2354 @category{Package distrib}
2361 @deffn {Function} random_exp (@var{m}) @
2362 @fname{random_exp} (@var{m},@var{k})
2364 Returns an m4_Exponential_RV(m) random variate, with @math{m>0}. Calling @code{random_exp} with a second argument @var{k}, a random sample of size @var{k} will be simulated.
2366 The simulation algorithm is based on the general inverse method.
2368 To make use of this function, write first @code{load("distrib")}.
2370 @opencatbox{Categories:}
2371 @category{Package distrib}
2372 @category{Random numbers}
2378 @node Lognormal Random Variable, Gamma Random Variable, Exponential Random Variable, Functions and Variables for continuous distributions
2379 @subsection Lognormal Random Variable
2381 The @emph{lognormal} distribution is distribution for a random
2382 variable whose logarithm is normally distributed.
2384 @anchor{pdf_lognormal}
2385 @deffn {Function} pdf_lognormal (@var{x},@var{m},@var{s})
2386 Returns the value at @var{x} of the density function of a m4_Lognormal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2392 \displaystyle{1\over x s \sqrt{2\pi}}
2393 \exp\left(-\displaystyle{\left(\log x - m\right)^2\over 2s^2}\right) & for $x \ge
2406 f(x, m, s) = [ --------------------- for x >= 0
2407 [ sqrt(2) sqrt(%pi) s x
2412 @opencatbox{Categories:}
2413 @category{Package distrib}
2419 @anchor{cdf_lognormal}
2420 @deffn {Function} cdf_lognormal (@var{x},@var{m},@var{s})
2421 Returns the value at @var{x} of the distribution function of a m4_Lognormal_RV(m,s) random variable, with @math{s>0}. This function is defined in terms of Maxima's built-in error function @code{erf}.
2427 \displaystyle{1\over 2}\left[1+{\rm erf}\left({\log x - m\over s\sqrt{2}}\right)\right] &
2437 F(x, m, s) = unit_step(x) (--------------- + -)
2443 @c load ("distrib")$
2444 @c cdf_lognormal(x,m,s);
2447 (%i1) load ("distrib")$
2449 (%i2) cdf_lognormal(x,m,s);
2453 (%o2) unit_step(x) (--------------- + -)
2458 See also @mrefdot{erf}
2460 @opencatbox{Categories:}
2461 @category{Package distrib}
2467 @anchor{quantile_lognormal}
2468 @deffn {Function} quantile_lognormal (@var{q},@var{m},@var{s})
2469 Returns the @var{q}-quantile of a m4_Lognormal_RV(m,s) random variable, with @math{s>0}; in other words, this is the inverse of @code{cdf_lognormal}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
2472 @c load ("distrib")$
2473 @c quantile_lognormal(95/100,0,1);
2477 (%i1) load ("distrib")$
2479 (%i2) quantile_lognormal(95/100,0,1);
2480 sqrt(2) inverse_erf(9/10)
2485 (%o3) 5.180251602233015
2489 @opencatbox{Categories:}
2490 @category{Package distrib}
2496 @anchor{mean_lognormal}
2497 @deffn {Function} mean_lognormal (@var{m},@var{s})
2498 Returns the mean of a m4_Lognormal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2502 <<<E[X] = \exp\left(m+{s^2\over 2}\right)>>>,
2514 @opencatbox{Categories:}
2515 @category{Package distrib}
2521 @anchor{var_lognormal}
2522 @deffn {Function} var_lognormal (@var{m},@var{s})
2523 Returns the variance of a m4_Lognormal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2527 <<<V[X] = \left(\exp\left(s^2\right) - 1\right) \exp\left(2m+s^2\right)>>>,
2537 @opencatbox{Categories:}
2538 @category{Package distrib}
2543 @anchor{std_lognormal}
2544 @deffn {Function} std_lognormal (@var{m},@var{s})
2545 Returns the standard deviation of a m4_Lognormal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2547 The standard deviation is
2549 <<<D[X] = \sqrt{\left(\exp\left(s^2\right) - 1\right)}
2550 \exp\left(m+{s^2\over 2}\right)>>>,
2557 D[X] = sqrt(%e - 1) %e
2562 @opencatbox{Categories:}
2563 @category{Package distrib}
2569 @anchor{skewness_lognormal}
2570 @deffn {Function} skewness_lognormal (@var{m},@var{s})
2571 Returns the skewness coefficient of a m4_Lognormal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2573 The skewness coefficient is
2575 <<<SK[X] = \left(\exp\left(s^2\right)+2\right)\sqrt{\exp\left(s^2\right)-1}>>>,
2580 SK[X] = sqrt(%e - 1) (%e + 2)
2584 @opencatbox{Categories:}
2585 @category{Package distrib}
2591 @anchor{kurtosis_lognormal}
2592 @deffn {Function} kurtosis_lognormal (@var{m},@var{s})
2593 Returns the kurtosis coefficient of a m4_Lognormal_RV(m,s) random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2595 The kurtosis coefficient is
2597 <<<KU[X] = \exp\left(4s^2\right)+2\exp\left(3s^2\right)+3\exp\left(2s^2\right)-3>>>,
2602 KU[X] = %e + 2 %e + 3 %e - 3
2608 @opencatbox{Categories:}
2609 @category{Package distrib}
2615 @anchor{random_lognormal}
2616 @deffn {Function} random_lognormal (@var{m},@var{s}) @
2617 @fname{random_lognormal} (@var{m},@var{s},@var{n})
2619 Returns a m4_Lognormal_RV(m,s) random variate, with @math{s>0}. Calling @code{random_lognormal} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
2621 Log-normal variates are simulated by means of random normal variates. See @code{random_normal} for details.
2623 To make use of this function, write first @code{load("distrib")}.
2625 @opencatbox{Categories:}
2626 @category{Package distrib}
2627 @category{Random numbers}
2633 @node Gamma Random Variable, Beta Random Variable, Lognormal Random Variable, Functions and Variables for continuous distributions
2634 @subsection Gamma Random Variable
2636 The @emph{gamma distribution} is a two-parameter family of probability
2637 distributions. Maxima uses the parameterization using the shape and
2638 scale for the first and second parameters of the distribution.
2641 @deffn {Function} pdf_gamma (@var{x},@var{a},@var{b})
2642 Returns the value at @var{x} of the density function of a m4_Gamma_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2644 The shape parameter is @math{a}, and the scale parameter is @math{b}.
2648 <<<f(x; a, b) = {x^{a-1}e^{-x/b}\over b^a \Gamma(a)}>>>,
2653 f(x, a, b) = ---------------------------
2659 @opencatbox{Categories:}
2660 @category{Package distrib}
2667 @deffn {Function} cdf_gamma (@var{x},@var{a},@var{b})
2668 Returns the value at @var{x} of the distribution function of a m4_Gamma_RV(a,b) random variable, with @math{a,b>0}.
2674 1-Q(a,{x\over b}) & for $x \ge 0$ \cr
2680 [ 1 - Q(a,x/b) for x>= 0
2685 where @math{Q(a,z)} is the @ref{gamma_incomplete_regularized} function.
2687 @c load ("distrib")$
2688 @c cdf_gamma(3,5,21);
2692 (%i1) load ("distrib")$
2694 (%i2) cdf_gamma(3,5,21);
2696 (%o2) 1 - gamma_incomplete_regularized(5, -)
2701 (%o3) 4.402663157376807e-7
2705 @opencatbox{Categories:}
2706 @category{Package distrib}
2712 @anchor{quantile_gamma}
2713 @deffn {Function} quantile_gamma (@var{q},@var{a},@var{b})
2714 Returns the @var{q}-quantile of a m4_Gamma_RV(a,b) random variable, with @math{a,b>0}; in other words, this is the inverse of @code{cdf_gamma}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
2716 @opencatbox{Categories:}
2717 @category{Package distrib}
2724 @deffn {Function} mean_gamma (@var{a},@var{b})
2725 Returns the mean of a m4_Gamma_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2736 @opencatbox{Categories:}
2737 @category{Package distrib}
2744 @deffn {Function} var_gamma (@var{a},@var{b})
2745 Returns the variance of a m4_Gamma_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2757 @opencatbox{Categories:}
2758 @category{Package distrib}
2764 @deffn {Function} std_gamma (@var{a},@var{b})
2765 Returns the standard deviation of a m4_Gamma_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2767 The standard deviation is
2769 <<<D[X] = b\sqrt{a}>>>,
2776 @opencatbox{Categories:}
2777 @category{Package distrib}
2783 @anchor{skewness_gamma}
2784 @deffn {Function} skewness_gamma (@var{a},@var{b})
2785 Returns the skewness coefficient of a m4_Gamma_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2787 The skewness coefficient is
2789 <<<SK[X] = {2\over \sqrt{a}}>>>,
2798 @opencatbox{Categories:}
2799 @category{Package distrib}
2805 @anchor{kurtosis_gamma}
2806 @deffn {Function} kurtosis_gamma (@var{a},@var{b})
2807 Returns the kurtosis coefficient of a m4_Gamma_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2809 The kurtosis coefficient is
2811 <<<KU[X] = {6\over a}>>>,
2821 @opencatbox{Categories:}
2822 @category{Package distrib}
2828 @anchor{random_gamma}
2829 @deffn {Function} random_gamma (@var{a},@var{b}) @
2830 @fname{random_gamma} (@var{a},@var{b},@var{n})
2832 Returns a m4_Gamma_RV(a,b) random variate, with @math{a,b>0}. Calling @code{random_gamma} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
2834 The implemented algorithm is a combination of two procedures, depending on the value of parameter @var{a}:
2836 For @math{a>=1}, Cheng, R.C.H. and Feast, G.M. (1979). @var{Some simple gamma variate generators}. Appl. Stat., 28, 3, 290-295.
2838 For @math{0<a<1}, Ahrens, J.H. and Dieter, U. (1974). @var{Computer methods for sampling from gamma, , poisson and binomial cdf_tributions}. Computing, 12, 223-246.
2840 To make use of this function, write first @code{load("distrib")}.
2842 @opencatbox{Categories:}
2843 @category{Package distrib}
2844 @category{Random numbers}
2850 @node Beta Random Variable, Continuous Uniform Random Variable, Gamma Random Variable, Functions and Variables for continuous distributions
2851 @subsection Beta Random Variable
2853 The @emph{beta} distribution is a family of distributions defined over
2854 @math{[0,1]} parameterized by two positive shape parameters @math{a},
2858 @deffn {Function} pdf_beta (@var{x},@var{a},@var{b})
2859 Returns the value at @var{x} of the density function of a m4_Beta_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2865 \displaystyle{x^{a-1}(1-x)^{b-1} \over B(a,b)} & for $0 \le x \le 1$
2874 f(x, a, b) = [ ------------------- for 0 <= x <= 1
2881 @opencatbox{Categories:}
2882 @category{Package distrib}
2890 @deffn {Function} cdf_beta (@var{x},@var{a},@var{b})
2891 Returns the value at @var{x} of the distribution function of a m4_Beta_RV(a,b) random variable, with @math{a,b>0}.
2898 I_x(a,b) & $0 \le x \le 1$ \cr
2905 F(x, a, b) = [ beta_incomplete_regularized(a, b, x) for 0 <= x <= 1
2911 @c load ("distrib")$
2912 @c cdf_beta(1/3,15,2);
2916 (%i1) load ("distrib")$
2918 (%i2) cdf_beta(1/3,15,2);
2925 (%o3) 7.666089131388195e-7
2929 @opencatbox{Categories:}
2930 @category{Package distrib}
2936 @anchor{quantile_beta}
2937 @deffn {Function} quantile_beta (@var{q},@var{a},@var{b})
2938 Returns the @var{q}-quantile of a m4_Beta_RV(a,b) random variable, with @math{a,b>0}; in other words, this is the inverse of @code{cdf_beta}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
2940 @opencatbox{Categories:}
2941 @category{Package distrib}
2948 @deffn {Function} mean_beta (@var{a},@var{b})
2949 Returns the mean of a m4_Beta_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2953 <<<E[X] = {a\over a+b}>>>,
2962 @opencatbox{Categories:}
2963 @category{Package distrib}
2970 @deffn {Function} var_beta (@var{a},@var{b})
2971 Returns the variance of a m4_Beta_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2975 <<<V[X] = {ab \over (a+b)^2(a+b+1)}>>>,
2979 V[X] = --------------------
2985 @opencatbox{Categories:}
2986 @category{Package distrib}
2992 @deffn {Function} std_beta (@var{a},@var{b})
2993 Returns the standard deviation of a m4_Beta_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2995 The standard deviation is
2997 <<<D[X] = {1\over a+b}\sqrt{ab\over a+b+1}>>>,
3003 D[X] = ---------------
3008 @opencatbox{Categories:}
3009 @category{Package distrib}
3015 @anchor{skewness_beta}
3016 @deffn {Function} skewness_beta (@var{a},@var{b})
3017 Returns the skewness coefficient of a m4_Beta_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3019 The skewness coefficient is
3021 <<<SK[X] = {2(b-a)\sqrt{a+b+1} \over (a+b+2)\sqrt{ab}}>>>,
3024 2 (b - a) sqrt(b + a + 1)
3025 SK[X] = -------------------------
3026 sqrt(a b) (b + a + 2)
3029 @opencatbox{Categories:}
3030 @category{Package distrib}
3036 @anchor{kurtosis_beta}
3037 @deffn {Function} kurtosis_beta (@var{a},@var{b})
3038 Returns the kurtosis coefficient of a m4_Beta_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3040 The kurtosis coefficient is
3042 <<<KU[X] = {3(a+b+1)\left(2(a+b)^2+ab(a+b-6)\right) \over
3043 ab(a+b+2)(a+b+3)} - 3>>>,
3047 3 (b + a + 1) (2 (b + a) + a b (b + a - 6))
3048 KU[X] = -------------------------------------------- - 3
3049 a b (b + a + 2) (b + a + 3)
3053 @opencatbox{Categories:}
3054 @category{Package distrib}
3060 @anchor{random_beta}
3061 @deffn {Function} random_beta (@var{a},@var{b}) @
3062 @fname{random_beta} (@var{a},@var{b},@var{n})
3064 Returns a m4_Beta_RV(a,b) random variate, with @math{a,b>0}. Calling @code{random_beta} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3066 The implemented algorithm is defined in Cheng, R.C.H. (1978). @var{Generating Beta Variates with Nonintegral Shape Parameters}. Communications of the ACM, 21:317-322
3068 To make use of this function, write first @code{load("distrib")}.
3070 @opencatbox{Categories:}
3071 @category{Package distrib}
3072 @category{Random numbers}
3077 @node Continuous Uniform Random Variable, Logistic Random Variable, Beta Random Variable, Functions and Variables for continuous distributions
3078 @subsection Continuous Uniform Random Variable
3080 The @emph{continuous uniform} distribution is constant over the
3081 interval @math{[a,b]} and is zero elsewhere.
3083 @anchor{pdf_continuous_uniform}
3084 @deffn {Function} pdf_continuous_uniform (@var{x},@var{a},@var{b})
3085 Returns the value at @var{x} of the density function of a m4_Continuous_Uniform_RV(a,b) random variable, with @math{a<b}. To make use of this function, write first @code{load("distrib")}.
3091 \displaystyle{1\over b-a} & for $0 \le x \le 1$ \cr
3097 [ 1/(b-a) for 0 <= x <= 1
3104 @opencatbox{Categories:}
3105 @category{Package distrib}
3111 @anchor{cdf_continuous_uniform}
3112 @deffn {Function} cdf_continuous_uniform (@var{x},@var{a},@var{b})
3113 Returns the value at @var{x} of the distribution function of a m4_Continuous_Uniform_RV(a,b) random variable, with @math{a<b}. To make use of this function, write first @code{load("distrib")}.
3121 \displaystyle{x-a\over b-a} & for $a \le x \le b$ \cr
3128 F(x,a,b) = [ (x-a)/(b-a) for a <= x <= b
3132 @opencatbox{Categories:}
3133 @category{Package distrib}
3139 @anchor{quantile_continuous_uniform}
3140 @deffn {Function} quantile_continuous_uniform (@var{q},@var{a},@var{b})
3141 Returns the @var{q}-quantile of a m4_Continuous_Uniform_RV(a,b) random variable, with @math{a<b}; in other words, this is the inverse of @code{cdf_continuous_uniform}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3143 @opencatbox{Categories:}
3144 @category{Package distrib}
3150 @anchor{mean_continuous_uniform}
3151 @deffn {Function} mean_continuous_uniform (@var{a},@var{b})
3152 Returns the mean of a m4_Continuous_Uniform_RV(a,b) random variable, with @math{a<b}. To make use of this function, write first @code{load("distrib")}.
3156 <<<E[X] = {a+b\over 2}>>>,
3165 @opencatbox{Categories:}
3166 @category{Package distrib}
3172 @anchor{var_continuous_uniform}
3173 @deffn {Function} var_continuous_uniform (@var{a},@var{b})
3174 Returns the variance of a m4_Continuous_Uniform_RV(a,b) random variable, with @math{a<b}. To make use of this function, write first @code{load("distrib")}.
3178 <<<V[X] = {(b-a)^2\over 12}>>>,
3188 @opencatbox{Categories:}
3189 @category{Package distrib}
3194 @anchor{std_continuous_uniform}
3195 @deffn {Function} std_continuous_uniform (@var{a},@var{b})
3196 Returns the standard deviation of a m4_Continuous_Uniform_RV(a,b) random variable, with @math{a<b}. To make use of this function, write first @code{load("distrib")}.
3198 The standard deviation is
3200 <<<D[X] = {b-a \over 2\sqrt{3}}>>>,
3210 @opencatbox{Categories:}
3211 @category{Package distrib}
3217 @anchor{skewness_continuous_uniform}
3218 @deffn {Function} skewness_continuous_uniform (@var{a},@var{b})
3219 Returns the skewness coefficient of a m4_Continuous_Uniform_RV(a,b) random variable, with @math{a<b}. To make use of this function, write first @code{load("distrib")}.
3221 The skewness coefficient is
3230 @opencatbox{Categories:}
3231 @category{Package distrib}
3237 @anchor{kurtosis_continuous_uniform}
3238 @deffn {Function} kurtosis_continuous_uniform (@var{a},@var{b})
3239 Returns the kurtosis coefficient of a m4_Continuous_Uniform_RV(a,b) random variable, with @math{a<b}. To make use of this function, write first @code{load("distrib")}.
3241 The kurtosis coefficient is
3243 <<<KU[X] = -{6\over5}>>>,
3250 @opencatbox{Categories:}
3251 @category{Package distrib}
3257 @anchor{random_continuous_uniform}
3258 @deffn {Function} random_continuous_uniform (@var{a},@var{b}) @
3259 @fname{random_continuous_uniform} (@var{a},@var{b},@var{n})
3261 Returns a m4_Continuous_Uniform_RV(a,b) random variate, with @math{a<b}. Calling @code{random_continuous_uniform} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3263 This is a direct application of the @code{random} built-in Maxima function.
3265 See also @mrefdot{random} To make use of this function, write first @code{load("distrib")}.
3267 @opencatbox{Categories:}
3268 @category{Package distrib}
3269 @category{Random numbers}
3275 @node Logistic Random Variable, Pareto Random Variable, Continuous Uniform Random Variable, Functions and Variables for continuous distributions
3276 @subsection Logistic Random Variable
3278 The @emph{logistic} distribution is a continuous distribution where
3279 it's cumulative distribution function is the logistic function.
3281 @anchor{pdf_logistic}
3282 @deffn {Function} pdf_logistic (@var{x},@var{a},@var{b})
3283 Returns the value at @var{x} of the density function of a m4_Logistic_RV(a,b) random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3285 @math{a} is the location parameter and @math{b} is the scale
3290 <<<f(x; a, b) = {e^{-(x-a)/b} \over b\left(1 + e^{-(x-a)/b}\right)^2}>>>,
3297 f(x, a, b) = ----------------
3304 @opencatbox{Categories:}
3305 @category{Package distrib}
3311 @anchor{cdf_logistic}
3312 @deffn {Function} cdf_logistic (@var{x},@var{a},@var{b})
3313 Returns the value at @var{x} of the distribution function of a m4_Logistic_RV(a,b) random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3317 <<<F(x; a, b) = {1\over 1+e^{-(x-a)/b}}>>>,
3321 F(x, a, b) = -----------
3329 @opencatbox{Categories:}
3330 @category{Package distrib}
3336 @anchor{quantile_logistic}
3337 @deffn {Function} quantile_logistic (@var{q},@var{a},@var{b})
3338 Returns the @var{q}-quantile of a m4_Logistic_RV(a,b) random variable , with @math{b>0}; in other words, this is the inverse of @code{cdf_logistic}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3340 @opencatbox{Categories:}
3341 @category{Package distrib}
3347 @anchor{mean_logistic}
3348 @deffn {Function} mean_logistic (@var{a},@var{b})
3349 Returns the mean of a m4_Logistic_RV(a,b) random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3360 @opencatbox{Categories:}
3361 @category{Package distrib}
3367 @anchor{var_logistic}
3368 @deffn {Function} var_logistic (@var{a},@var{b})
3369 Returns the variance of a m4_Logistic_RV(a,b) random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3373 <<<V[X] = {\pi^2 b^2 \over 3}>>>,
3384 @opencatbox{Categories:}
3385 @category{Package distrib}
3391 @anchor{std_logistic}
3392 @deffn {Function} std_logistic (@var{a},@var{b})
3393 Returns the standard deviation of a m4_Logistic_RV(a,b) random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3395 The standard deviation is
3397 <<<D[X] = {\pi b\over \sqrt{3}}>>>,
3406 @opencatbox{Categories:}
3407 @category{Package distrib}
3413 @anchor{skewness_logistic}
3414 @deffn {Function} skewness_logistic (@var{a},@var{b})
3415 Returns the skewness coefficient of a m4_Logistic_RV(a,b) random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3417 The skewness coefficient is
3426 @opencatbox{Categories:}
3427 @category{Package distrib}
3433 @anchor{kurtosis_logistic}
3434 @deffn {Function} kurtosis_logistic (@var{a},@var{b})
3435 Returns the kurtosis coefficient of a m4_Logistic_RV(a,b) random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3437 The kurtosis coefficient is
3439 <<<KU[X] = {6\over 5}>>>,
3448 @opencatbox{Categories:}
3449 @category{Package distrib}
3455 @anchor{random_logistic}
3456 @deffn {Function} random_logistic (@var{a},@var{b}) @
3457 @fname{random_logistic} (@var{a},@var{b},@var{n})
3459 Returns a m4_Logistic_RV(a,b) random variate, with @math{b>0}. Calling @code{random_logistic} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3461 The implemented algorithm is based on the general inverse method.
3463 To make use of this function, write first @code{load("distrib")}.
3465 @opencatbox{Categories:}
3466 @category{Package distrib}
3467 @category{Random numbers}
3473 @node Pareto Random Variable, Weibull Random Variable, Logistic Random Variable, Functions and Variables for continuous distributions
3474 @subsection Pareto Random Variable
3477 @deffn {Function} pdf_pareto (@var{x},@var{a},@var{b})
3478 Returns the value at @var{x} of the density function of a m4_Pareto_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3484 \displaystyle{a b^a \over x^{a+1}} & for $x \ge b$ \cr
3490 [ a*b^a/x^(a+1) for x >= b
3496 @opencatbox{Categories:}
3497 @category{Package distrib}
3504 @deffn {Function} cdf_pareto (@var{x},@var{a},@var{b})
3505 Returns the value at @var{x} of the distribution function of a m4_Pareto_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3511 1-\left(\displaystyle{b\over x}\right)^a & for $x \ge b$\cr
3516 [ 1 - (b/x)^a for x >= 0
3521 @opencatbox{Categories:}
3522 @category{Package distrib}
3528 @anchor{quantile_pareto}
3529 @deffn {Function} quantile_pareto (@var{q},@var{a},@var{b})
3530 Returns the @var{q}-quantile of a m4_Pareto_RV(a,b) random variable, with @math{a,b>0}; in other words, this is the inverse of @code{cdf_pareto}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3532 @opencatbox{Categories:}
3533 @category{Package distrib}
3539 @anchor{mean_pareto}
3540 @deffn {Function} mean_pareto (@var{a},@var{b})
3541 Returns the mean of a m4_Pareto_RV(a,b) random variable, with @math{a>1,b>0}. To make use of this function, write first @code{load("distrib")}.
3545 <<<E[X] = {ab\over a-1}>>>,
3546 <<<@math{E[X] = a*b/(a-1)}>>>)
3548 @opencatbox{Categories:}
3549 @category{Package distrib}
3556 @deffn {Function} var_pareto (@var{a},@var{b})
3557 Returns the variance of a m4_Pareto_RV(a,b) random variable, with @math{a>2,b>0}. To make use of this function, write first @code{load("distrib")}.
3561 <<<V[X] = {ab^2\over (a-2)(a-1)^2}>>>,
3566 V[X] = ----------------
3572 @opencatbox{Categories:}
3573 @category{Package distrib}
3579 @deffn {Function} std_pareto (@var{a},@var{b})
3580 Returns the standard deviation of a m4_Pareto_RV(a,b) random variable, with @math{a>2,b>0}. To make use of this function, write first @code{load("distrib")}.
3582 The standard deviation is
3584 <<<D[X] = {b\over a-1} \sqrt{a\over a-2}>>>,
3590 D[X] = -------------
3595 @opencatbox{Categories:}
3596 @category{Package distrib}
3603 @anchor{skewness_pareto}
3604 @deffn {Function} skewness_pareto (@var{a},@var{b})
3605 Returns the skewness coefficient of a m4_Pareto_RV(a,b) random variable, with @math{a>3,b>0}. To make use of this function, write first @code{load("distrib")}.
3607 The skewness coefficient is
3609 <<<SK[X] = {2(a+1)\over a-3} \sqrt{a-2\over a}>>>,
3612 2 sqrt(a - 2) (a + 1)
3613 SK[X] = ---------------------
3618 @opencatbox{Categories:}
3619 @category{Package distrib}
3625 @anchor{kurtosis_pareto}
3626 @deffn {Function} kurtosis_pareto (@var{a},@var{b})
3627 Returns the kurtosis coefficient of a m4_Pareto_RV(a,b) random variable, with @math{a>4,b>0}. To make use of this function, write first @code{load("distrib")}.
3629 The kurtosis coefficient is
3631 <<<KU[X] = {6\left(a^3+a^2-6*a-2\right) \over a(a-3)(a-4)} - 3>>>,
3636 KU[X] = --------------------- - 3
3642 @opencatbox{Categories:}
3643 @category{Package distrib}
3649 @anchor{random_pareto}
3650 @deffn {Function} random_pareto (@var{a},@var{b}) @
3651 @fname{random_pareto} (@var{a},@var{b},@var{n})
3653 Returns a m4_Pareto_RV(a,b) random variate, with @math{a>0,b>0}. Calling @code{random_pareto} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3655 The implemented algorithm is based on the general inverse method.
3657 To make use of this function, write first @code{load("distrib")}.
3659 @opencatbox{Categories:}
3660 @category{Package distrib}
3661 @category{Random numbers}
3667 @node Weibull Random Variable, Rayleigh Random Variable, Pareto Random Variable, Functions and Variables for continuous distributions
3668 @subsection Weibull Random Variable
3670 @anchor{pdf_weibull}
3671 @deffn {Function} pdf_weibull (@var{x},@var{a},@var{b})
3672 Returns the value at @var{x} of the density function of a m4_Weibull_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3678 \displaystyle{1\over b} \left({x\over b}\right)^{a-1} e^{-(x/b)^a} &
3687 [ a (-) %e unit_step(x)
3689 [ ---------------------------------- for x >= 0
3695 @opencatbox{Categories:}
3696 @category{Package distrib}
3702 @anchor{cdf_weibull}
3703 @deffn {Function} cdf_weibull (@var{x},@var{a},@var{b})
3704 Returns the value at @var{x} of the distribution function of a m4_Weibull_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3710 1 - e^{-(x/b)^a} & for $x \ge 0$ \cr
3715 [ 1 - exp(-(x/b)^a) for x >= 0
3720 @opencatbox{Categories:}
3721 @category{Package distrib}
3727 @anchor{quantile_weibull}
3728 @deffn {Function} quantile_weibull (@var{q},@var{a},@var{b})
3729 Returns the @var{q}-quantile of a m4_Weibull_RV(a,b) random variable, with @math{a,b>0}; in other words, this is the inverse of @code{cdf_weibull}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3731 @opencatbox{Categories:}
3732 @category{Package distrib}
3738 @anchor{mean_weibull}
3739 @deffn {Function} mean_weibull (@var{a},@var{b})
3740 Returns the mean of a m4_Weibull_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3744 <<<E[X] = b\Gamma\left(1+{1\over a}\right)>>>,
3748 E[X] = gamma(- + 1) b
3753 @opencatbox{Categories:}
3754 @category{Package distrib}
3760 @anchor{var_weibull}
3761 @deffn {Function} var_weibull (@var{a},@var{b})
3762 Returns the variance of a m4_Weibull_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3766 <<<V[X] = b^2\left[\Gamma\left(1+{2\over a}\right) -
3767 \Gamma\left(1+{1\over a}\right)^2\right]>>>,
3771 V[X] = (gamma(- + 1) - gamma (- + 1)) b
3776 @opencatbox{Categories:}
3777 @category{Package distrib}
3782 @anchor{std_weibull}
3783 @deffn {Function} std_weibull (@var{a},@var{b})
3784 Returns the standard deviation of a m4_Weibull_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3788 <<<D[X] = b\sqrt{\Gamma\left(1+{2\over a}\right) -
3789 \Gamma\left(1+{1\over a}\right)^2}>>>,
3793 D[X] = sqrt(gamma(- + 1) - gamma (- + 1)) b
3798 @opencatbox{Categories:}
3799 @category{Package distrib}
3806 @anchor{skewness_weibull}
3807 @deffn {Function} skewness_weibull (@var{a},@var{b})
3808 Returns the skewness coefficient of a m4_Weibull_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3810 The skewness coefficient is
3812 <<<SK[X] = {\displaystyle\Gamma\left(1+{3\over a}\right)
3813 -3\Gamma\left(1+{1\over a}\right)\Gamma\left(1+{2\over
3814 a}\right)+2\Gamma\left(1+{1\over a}\right)^3
3816 \displaystyle\left[\Gamma\left(1+{2\over a}\right)-\Gamma\left(1+{1\over
3817 a}\right)^2\right]^{3/2}
3823 gamma(- + 1) - 3 gamma(- + 1) gamma(- + 1) + 2 gamma (- + 1)
3825 SK[X] = ------------------------------------------------------------
3827 (gamma(- + 1) - gamma (- + 1))
3832 @opencatbox{Categories:}
3833 @category{Package distrib}
3839 @anchor{kurtosis_weibull}
3840 @deffn {Function} kurtosis_weibull (@var{a},@var{b})
3841 Returns the kurtosis coefficient of a m4_Weibull_RV(a,b) random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3843 The kurtosis coefficient is
3847 - 4\Gamma_1 \Gamma_3
3848 + 6\Gamma_1^2 \Gamma_2
3851 \left[\Gamma_2 - \Gamma_1^2\right]^2
3856 KU[X] = (gamma(- + 1) - 4 gamma(- + 1) gamma(- + 1)
3859 + 6 gamma (- + 1) gamma(- + 1) - 3 gamma (- + 1))
3862 /(gamma(- + 1) - gamma (- + 1)) - 3
3867 where m4_math(\Gamma_k = \Gamma\left(1+k/a\right)).
3870 @opencatbox{Categories:}
3871 @category{Package distrib}
3877 @anchor{random_weibull}
3878 @deffn {Function} random_weibull (@var{a},@var{b}) @
3879 @fname{random_weibull} (@var{a},@var{b},@var{n})
3881 Returns a m4_Weibull_RV(a,b) random variate, with @math{a,b>0}. Calling @code{random_weibull} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3883 The implemented algorithm is based on the general inverse method.
3885 To make use of this function, write first @code{load("distrib")}.
3887 @opencatbox{Categories:}
3888 @category{Package distrib}
3889 @category{Random numbers}
3896 @node Rayleigh Random Variable, Laplace Random Variable, Weibull Random Variable, Functions and Variables for continuous distributions
3897 @subsection Rayleigh Random Variable
3899 The @emph{Rayleigh} distribution coincides with the m4_math(\chi^2,
3900 chi-squared) distribution with two degrees of freedom.
3902 @anchor{pdf_rayleigh}
3903 @deffn {Function} pdf_rayleigh (@var{x},@var{b})
3904 Returns the value at @var{x} of the density function of a m4_Rayleigh_RV(b) random variable, with @math{b>0}.
3906 The m4_Rayleigh_RV(b) random variable is equivalent to the m4_Weibull_RV(2,1/b).
3912 2b^2 x e^{-b^2 x^2} & for $x \ge 0$ \cr
3917 [ 2*b^2*x*exp(-b^2*x^2) for x>= 0
3923 @c load ("distrib")$
3924 @c pdf_rayleigh(x,b);
3927 (%i1) load ("distrib")$
3929 (%i2) pdf_rayleigh(x,b);
3932 (%o2) 2 b x %e unit_step(x)
3936 @opencatbox{Categories:}
3937 @category{Package distrib}
3943 @anchor{cdf_rayleigh}
3944 @deffn {Function} cdf_rayleigh (@var{x},@var{b})
3945 Returns the value at @var{x} of the distribution function of a m4_Rayleigh_RV(b) random variable, with @math{b>0}.
3947 The m4_Rayleigh_RV(b) random variable is equivalent to the m4_Weibull_RV(2,1/b).
3953 1 - e^{-b^2 x^2} & for $x \ge 0$\cr
3958 [ 1 - exp(-b^2*x^2) for x >= 0
3964 @c load ("distrib")$
3965 @c cdf_rayleigh(x,b);
3968 (%i1) load ("distrib")$
3970 (%i2) cdf_rayleigh(x,b);
3973 (%o2) (1 - %e ) unit_step(x)
3977 @opencatbox{Categories:}
3978 @category{Package distrib}
3984 @anchor{quantile_rayleigh}
3985 @deffn {Function} quantile_rayleigh (@var{q},@var{b})
3986 Returns the @var{q}-quantile of a m4_Rayleigh_RV(b) random variable, with @math{b>0}; in other words, this is the inverse of @code{cdf_rayleigh}. Argument @var{q} must be an element of @math{[0,1]}.
3988 The m4_Rayleigh_RV(b) random variable is equivalent to the m4_Weibull_RV(2,1/b).
3991 @c load ("distrib")$
3992 @c quantile_rayleigh(0.99,b);
3995 (%i1) load ("distrib")$
3997 (%i2) quantile_rayleigh(0.99,b);
3999 (%o2) -----------------
4004 @opencatbox{Categories:}
4005 @category{Package distrib}
4011 @anchor{mean_rayleigh}
4012 @deffn {Function} mean_rayleigh (@var{b})
4013 Returns the mean of a m4_Rayleigh_RV(b) random variable, with @math{b>0}.
4015 The m4_Rayleigh_RV(b) random variable is equivalent to the m4_Weibull_RV(2,1/b).
4019 <<<E[X] = {\sqrt{\pi}\over 2b}>>>,
4029 @c load ("distrib")$
4030 @c mean_rayleigh(b);
4033 (%i1) load ("distrib")$
4035 (%i2) mean_rayleigh(b);
4042 @opencatbox{Categories:}
4043 @category{Package distrib}
4049 @anchor{var_rayleigh}
4050 @deffn {Function} var_rayleigh (@var{b})
4051 Returns the variance of a m4_Rayleigh_RV(b) random variable, with @math{b>0}.
4053 The m4_Rayleigh_RV(b) random variable is equivalent to the m4_Weibull_RV(2,1/b).
4057 <<<V[X] = {1\over b^2}\left(1-{\pi \over 4}\right)>>>,
4070 @c load ("distrib")$
4074 (%i1) load ("distrib")$
4076 (%i2) var_rayleigh(b);
4086 @opencatbox{Categories:}
4087 @category{Package distrib}
4093 @anchor{std_rayleigh}
4094 @deffn {Function} std_rayleigh (@var{b})
4095 Returns the standard deviation of a m4_Rayleigh_RV(b) random variable, with @math{b>0}.
4097 The m4_Rayleigh_RV(b) random variable is equivalent to the m4_Weibull_RV(2,1/b).
4099 The standard deviation is
4101 <<<D[X] = {1\over b}\sqrt{\displaystyle 1 - {\pi\over 4}}>>>,
4107 D[X] = -------------
4113 @c load ("distrib")$
4117 (%i1) load ("distrib")$
4119 (%i2) std_rayleigh(b);
4128 @opencatbox{Categories:}
4129 @category{Package distrib}
4135 @anchor{skewness_rayleigh}
4136 @deffn {Function} skewness_rayleigh (@var{b})
4137 Returns the skewness coefficient of a m4_Rayleigh_RV(b) random variable, with @math{b>0}.
4139 The m4_Rayleigh_RV(b) random variable is equivalent to the m4_Weibull_RV(2,1/b).
4141 The skewness coefficient is
4143 <<<SK[X] = {2\sqrt{\pi}(\pi - 3)\over (4-\pi)^{3/2}}>>>,
4148 ------ - -----------
4150 SK[X] = --------------------
4158 @c load ("distrib")$
4159 @c skewness_rayleigh(b);
4162 (%i1) load ("distrib")$
4164 (%i2) skewness_rayleigh(b);
4167 ------ - -----------
4169 (%o2) --------------------
4176 @opencatbox{Categories:}
4177 @category{Package distrib}
4183 @anchor{kurtosis_rayleigh}
4184 @deffn {Function} kurtosis_rayleigh (@var{b})
4185 Returns the kurtosis coefficient of a m4_Rayleigh_RV(b) random variable, with @math{b>0}.
4187 The m4_Rayleigh_RV(b) random variable is equivalent to the m4_Weibull_RV(2,1/b).
4189 The kurtosis coefficient is
4191 <<<KU[X] = {32-3\pi\over (4-\pi)^2} - 3>>>,
4198 KU[X] = ---------- - 3
4206 @c load ("distrib")$
4207 @c kurtosis_rayleigh(b);
4210 (%i1) load ("distrib")$
4212 (%i2) kurtosis_rayleigh(b);
4217 (%o2) ---------- - 3
4224 @opencatbox{Categories:}
4225 @category{Package distrib}
4231 @anchor{random_rayleigh}
4232 @deffn {Function} random_rayleigh (@var{b}) @
4233 @fname{random_rayleigh} (@var{b},@var{n})
4235 Returns a m4_Rayleigh_RV(b) random variate, with @math{b>0}. Calling @code{random_rayleigh} with a second argument @var{n}, a random sample of size @var{n} will be simulated.
4237 The implemented algorithm is based on the general inverse method.
4239 To make use of this function, write first @code{load("distrib")}.
4241 @opencatbox{Categories:}
4242 @category{Package distrib}
4243 @category{Random numbers}
4250 @node Laplace Random Variable, Cauchy Random Variable, Rayleigh Random Variable, Functions and Variables for continuous distributions
4251 @subsection Laplace Random Variable
4253 The @emph{Laplace} distribution is a continuous probability
4254 distribution that is sometimes called the double exponential
4255 distribution because it can be thought of as two exponential
4256 distributions spliced back to back.
4258 @anchor{pdf_laplace}
4259 @deffn {Function} pdf_laplace (@var{x},@var{a},@var{b})
4260 Returns the value at @var{x} of the density function of a m4_Laplace_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4262 Here, @math{a} is the location parameter (or mean), and @math{b} is
4263 the scale parameter, related to the variance.
4267 <<<f(x; a, b) = {1\over 2b}\exp\left(-{|x-a|\over b}\right)>>>,
4274 f(x, a, b) = --------------
4277 @math{1/(2*b)*exp(-abs(x-a)/b)}>>>)
4279 @opencatbox{Categories:}
4280 @category{Package distrib}
4286 @anchor{cdf_laplace}
4287 @deffn {Function} cdf_laplace (@var{x},@var{a},@var{b})
4288 Returns the value at @var{x} of the distribution function of a m4_Laplace_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4294 \displaystyle{1\over 2} \exp\left({x-a\over b}\right) & for $x < a$\cr
4296 1-\displaystyle{1\over 2} \exp\left({x-a\over b}\right) & for $x \ge a$
4300 [ 1/2*exp((x-a)/b) for x < a
4302 [ 1-1/2*exp((x-a)/b) for x >= a
4305 @opencatbox{Categories:}
4306 @category{Package distrib}
4312 @anchor{quantile_laplace}
4313 @deffn {Function} quantile_laplace (@var{q},@var{a},@var{b})
4314 Returns the @var{q}-quantile of a m4_Laplace_RV(a,b) random variable, with @math{b>0}; in other words, this is the inverse of @code{cdf_laplace}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
4316 @opencatbox{Categories:}
4317 @category{Package distrib}
4323 @anchor{mean_laplace}
4324 @deffn {Function} mean_laplace (@var{a},@var{b})
4325 Returns the mean of a m4_Laplace_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4336 @opencatbox{Categories:}
4337 @category{Package distrib}
4343 @anchor{var_laplace}
4344 @deffn {Function} var_laplace (@var{a},@var{b})
4345 Returns the variance of a m4_Laplace_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4357 @opencatbox{Categories:}
4358 @category{Package distrib}
4364 @anchor{std_laplace}
4365 @deffn {Function} std_laplace (@var{a},@var{b})
4366 Returns the standard deviation of a m4_Laplace_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4368 The standard deviation is
4370 <<<D[X] = \sqrt{2} b>>>,
4377 @opencatbox{Categories:}
4378 @category{Package distrib}
4384 @anchor{skewness_laplace}
4385 @deffn {Function} skewness_laplace (@var{a},@var{b})
4386 Returns the skewness coefficient of a m4_Laplace_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4388 The skewness coefficient is
4397 @opencatbox{Categories:}
4398 @category{Package distrib}
4404 @anchor{kurtosis_laplace}
4405 @deffn {Function} kurtosis_laplace (@var{a},@var{b})
4406 Returns the kurtosis coefficient of a m4_Laplace_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4408 The kurtosis coefficient is
4417 @opencatbox{Categories:}
4418 @category{Package distrib}
4424 @anchor{random_laplace}
4425 @deffn {Function} random_laplace (@var{a},@var{b}) @
4426 @fname{random_laplace} (@var{a},@var{b},@var{n})
4428 Returns a m4_Laplace_RV(a,b) random variate, with @math{b>0}. Calling @code{random_laplace} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
4430 The implemented algorithm is based on the general inverse method.
4432 To make use of this function, write first @code{load("distrib")}.
4434 @opencatbox{Categories:}
4435 @category{Package distrib}
4436 @category{Random numbers}
4443 @node Cauchy Random Variable, Gumbel Random Variable, Laplace Random Variable, Functions and Variables for continuous distributions
4444 @subsection Cauchy Random Variable
4446 The @emph{Cauchy} distribution (also known as the Lorentz
4447 distribution) is the distribution of of the ratio of two independent
4448 normally distributed random variables with mean zero.
4450 Note that the mean, variance, standard deviation, skewness
4451 coefficient, and kurtosis coefficient are all undefined for the Cauchy
4452 distribution. The integrals do not converge in this case.
4455 @deffn {Function} pdf_cauchy (@var{x},@var{a},@var{b})
4456 Returns the value at @var{x} of the density function of a m4_Cauchy_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4460 <<<f(x; a, b) = {b\over \pi\left((x-a)^2+b^2\right)}>>>,
4464 f(x, a, b) = -------------------
4469 @opencatbox{Categories:}
4470 @category{Package distrib}
4477 @deffn {Function} cdf_cauchy (@var{x},@var{a},@var{b})
4478 Returns the value at @var{x} of the distribution function of a m4_Cauchy_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4482 <<<F(x; a, b) = {1\over 2} + {1\over \pi} \tan^{-1} {x-a\over b}>>>,
4488 F(x, a, b) = ----------- + -
4492 @opencatbox{Categories:}
4493 @category{Package distrib}
4499 @anchor{quantile_cauchy}
4500 @deffn {Function} quantile_cauchy (@var{q},@var{a},@var{b})
4501 Returns the @var{q}-quantile of a m4_Cauchy_RV(a,b) random variable, with @math{b>0}; in other words, this is the inverse of @code{cdf_cauchy}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
4503 @opencatbox{Categories:}
4504 @category{Package distrib}
4510 @anchor{random_cauchy}
4511 @deffn {Function} random_cauchy (@var{a},@var{b}) @
4512 @fname{random_cauchy} (@var{a},@var{b},@var{n})
4514 Returns a m4_Cauchy_RV(a,b) random variate, with @math{b>0}. Calling @code{random_cauchy} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
4516 The implemented algorithm is based on the general inverse method.
4518 To make use of this function, write first @code{load("distrib")}.
4520 @opencatbox{Categories:}
4521 @category{Package distrib}
4522 @category{Random numbers}
4529 @node Gumbel Random Variable, , Cauchy Random Variable, Functions and Variables for continuous distributions
4530 @subsection Gumbel Random Variable
4533 @deffn {Function} pdf_gumbel (@var{x},@var{a},@var{b})
4534 Returns the value at @var{x} of the density function of a m4_Gumbel_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4538 <<<f(x; a, b) = {1\over b} \exp\left[{a-x\over b} - \exp\left({a-x\over b}\right)\right]>>>,
4547 f(x, a, b) = -----------------
4552 @opencatbox{Categories:}
4553 @category{Package distrib}
4560 @deffn {Function} cdf_gumbel (@var{x},@var{a},@var{b})
4561 Returns the value at @var{x} of the distribution function of a m4_Gumbel_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4565 <<<F(x; a, b) = \exp\left[-\exp\left({a-x\over b}\right)\right]>>>,
4575 @opencatbox{Categories:}
4576 @category{Package distrib}
4582 @anchor{quantile_gumbel}
4583 @deffn {Function} quantile_gumbel (@var{q},@var{a},@var{b})
4584 Returns the @var{q}-quantile of a m4_Gumbel_RV(a,b) random variable, with @math{b>0}; in other words, this is the inverse of @code{cdf_gumbel}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
4586 @opencatbox{Categories:}
4587 @category{Package distrib}
4593 @anchor{mean_gumbel}
4594 @deffn {Function} mean_gumbel (@var{a},@var{b})
4595 Returns the mean of a m4_Gumbel_RV(a,b) random variable, with @math{b>0}.
4599 <<<E[X] = a+b\gamma>>>,
4607 @c load ("distrib")$
4608 @c mean_gumbel(a,b);
4611 (%i1) load ("distrib")$
4613 (%i2) mean_gumbel(a,b);
4617 where symbol @code{%gamma} stands for the Euler-Mascheroni constant. See also @mrefdot{%gamma}
4619 @opencatbox{Categories:}
4620 @category{Package distrib}
4627 @deffn {Function} var_gumbel (@var{a},@var{b})
4628 Returns the variance of a m4_Gumbel_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4632 <<<V[X] = {\pi^2\over 6} b^2>>>,
4642 @opencatbox{Categories:}
4643 @category{Package distrib}
4650 @deffn {Function} std_gumbel (@var{a},@var{b})
4651 Returns the standard deviation of a m4_Gumbel_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4653 The standard deviation is
4655 <<<D[X] = {\pi \over \sqrt{6}} b>>>,
4664 @opencatbox{Categories:}
4665 @category{Package distrib}
4671 @anchor{skewness_gumbel}
4672 @deffn {Function} skewness_gumbel (@var{a},@var{b})
4673 Returns the skewness coefficient of a m4_Gumbel_RV(a,b) random variable, with @math{b>0}.
4675 The skewness coefficient is
4677 <<<SK[X] = {12\sqrt{6}\over \pi^3} \zeta(3)>>>,
4682 SK[X] = --------------
4689 @c load ("distrib")$
4690 @c skewness_gumbel(a,b);
4693 (%i1) load ("distrib")$
4695 (%i2) skewness_gumbel(a,b);
4698 (%o2) --------------
4703 where @code{zeta} stands for the Riemann's zeta function.
4705 @opencatbox{Categories:}
4706 @category{Package distrib}
4712 @anchor{kurtosis_gumbel}
4713 @deffn {Function} kurtosis_gumbel (@var{a},@var{b})
4714 Returns the kurtosis coefficient of a m4_Gumbel_RV(a,b) random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4716 The kurtosis coefficient is
4718 <<<KU[X] = {12\over 5}>>>,
4727 @opencatbox{Categories:}
4728 @category{Package distrib}
4729 @category{Package distrib}
4735 @anchor{random_gumbel}
4736 @deffn {Function} random_gumbel (@var{a},@var{b}) @
4737 @fname{random_gumbel} (@var{a},@var{b},@var{n})
4739 Returns a m4_Gumbel_RV(a,b) random variate, with @math{b>0}. Calling @code{random_gumbel} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
4741 The implemented algorithm is based on the general inverse method.
4743 To make use of this function, write first @code{load("distrib")}.
4745 @opencatbox{Categories:}
4746 @category{Package distrib}
4747 @category{Random numbers}
4753 @node Functions and Variables for discrete distributions, , Functions and Variables for continuous distributions
4754 @section Functions and Variables for discrete distributions
4756 Maxima knows the following kinds of discrete distributions
4760 * General Finite Discrete Random Variable::
4761 * Binomial Random Variable::
4762 * Poisson Random Variable::
4763 * Bernoulli Random Variable::
4764 * Geometric Random Variable::
4765 * Discrete Uniform Random Variable::
4766 * Hypergeometric Random Variable::
4767 * Negative Binomial Random Variable::
4770 @node General Finite Discrete Random Variable, Binomial Random Variable, Functions and Variables for discrete distributions, Functions and Variables for discrete distributions
4771 @subsection General Finite Discrete Random Variable
4773 @anchor{pdf_general_finite_discrete}
4774 @deffn {Function} pdf_general_finite_discrete (@var{x},@var{v})
4775 Returns the value at @var{x} of the probability function of a general finite discrete random variable, with vector probabilities @math{v}, such that @code{Pr(X=i) = v_i}. Vector @math{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 @code{load("distrib")}.
4778 @c load ("distrib")$
4779 @c pdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
4780 @c pdf_general_finite_discrete(2, [1, 4, 2]);
4783 (%i1) load ("distrib")$
4785 (%i2) pdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
4791 (%i3) pdf_general_finite_discrete(2, [1, 4, 2]);
4798 @opencatbox{Categories:}
4799 @category{Package distrib}
4805 @anchor{cdf_general_finite_discrete}
4806 @deffn {Function} cdf_general_finite_discrete (@var{x},@var{v})
4807 Returns the value at @var{x} of the distribution function of a general finite discrete random variable, with vector probabilities @math{v}.
4809 See @code{pdf_general_finite_discrete} for more details.
4812 @c load ("distrib")$
4813 @c cdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
4814 @c cdf_general_finite_discrete(2, [1, 4, 2]);
4815 @c cdf_general_finite_discrete(2+1/2, [1, 4, 2]);
4818 (%i1) load ("distrib")$
4820 (%i2) cdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
4826 (%i3) cdf_general_finite_discrete(2, [1, 4, 2]);
4832 (%i4) cdf_general_finite_discrete(2+1/2, [1, 4, 2]);
4839 @opencatbox{Categories:}
4840 @category{Package distrib}
4846 @anchor{quantile_general_finite_discrete}
4847 @deffn {Function} quantile_general_finite_discrete (@var{q},@var{v})
4848 Returns the @var{q}-quantile of a general finite discrete random variable, with vector probabilities @math{v}.
4850 See @code{pdf_general_finite_discrete} for more details.
4852 @opencatbox{Categories:}
4853 @category{Package distrib}
4859 @anchor{mean_general_finite_discrete}
4860 @deffn {Function} mean_general_finite_discrete (@var{v})
4861 Returns the mean of a general finite discrete random variable, with vector probabilities @math{v}.
4863 See @code{pdf_general_finite_discrete} for more details.
4865 @opencatbox{Categories:}
4866 @category{Package distrib}
4872 @anchor{var_general_finite_discrete}
4873 @deffn {Function} var_general_finite_discrete (@var{v})
4874 Returns the variance of a general finite discrete random variable, with vector probabilities @math{v}.
4876 See @code{pdf_general_finite_discrete} for more details.
4878 @opencatbox{Categories:}
4879 @category{Package distrib}
4885 @anchor{std_general_finite_discrete}
4886 @deffn {Function} std_general_finite_discrete (@var{v})
4887 Returns the standard deviation of a general finite discrete random variable, with vector probabilities @math{v}.
4889 See @code{pdf_general_finite_discrete} for more details.
4891 @opencatbox{Categories:}
4892 @category{Package distrib}
4898 @anchor{skewness_general_finite_discrete}
4899 @deffn {Function} skewness_general_finite_discrete (@var{v})
4900 Returns the skewness coefficient of a general finite discrete random variable, with vector probabilities @math{v}.
4902 See @code{pdf_general_finite_discrete} for more details.
4904 @opencatbox{Categories:}
4905 @category{Package distrib}
4911 @anchor{kurtosis_general_finite_discrete}
4912 @deffn {Function} kurtosis_general_finite_discrete (@var{v})
4913 Returns the kurtosis coefficient of a general finite discrete random variable, with vector probabilities @math{v}.
4915 See @code{pdf_general_finite_discrete} for more details.
4917 @opencatbox{Categories:}
4918 @category{Package distrib}
4924 @anchor{random_general_finite_discrete}
4925 @deffn {Function} random_general_finite_discrete (@var{v}) @
4926 @fname{random_general_finite_discrete} (@var{v},@var{m})
4928 Returns a general finite discrete random variate, with vector probabilities @math{v}. Calling @code{random_general_finite_discrete} with a second argument @var{m}, a random sample of size @var{m} will be simulated.
4930 See @code{pdf_general_finite_discrete} for more details.
4933 @c load ("distrib")$
4934 @c random_general_finite_discrete([1,3,1,5]);
4935 @c random_general_finite_discrete([1,3,1,5], 10);
4938 (%i1) load ("distrib")$
4940 (%i2) random_general_finite_discrete([1,3,1,5]);
4944 (%i3) random_general_finite_discrete([1,3,1,5], 10);
4945 (%o3) [3, 4, 3, 4, 4, 4, 4, 2, 4, 4]
4949 @opencatbox{Categories:}
4950 @category{Package distrib}
4951 @category{Random numbers}
4956 @node Binomial Random Variable, Poisson Random Variable, General Finite Discrete Random Variable, Functions and Variables for discrete distributions
4957 @subsection Binomial Random Variable
4959 The @emph{binomial distribution} with parameters @math{n} and @math{p}
4960 is a discrete probability distribution. It consists of @math{n}
4961 independent experiments where each experiment consists of a
4962 Boolean-valued outcome where a success occurs with a probablity
4965 For example, a biased coin that comes up heads with probablity
4966 @math{p} is tossed @math{n} times. Then the probability of exactly
4967 @math{k} heads in @math{n} tosses is given by the binomial
4970 @anchor{pdf_binomial}
4971 @deffn {Function} pdf_binomial (@var{x},@var{n},@var{p})
4972 Returns the value at @var{x} of the probability function of a m4_Binomial_RV(n,p) random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
4976 <<<f(x; n, p) = {n\choose x} (1-p)^{n-x}p^x>>>,
4980 f(x, n, p) = binomial(n, x) (1 - p) p
4984 @opencatbox{Categories:}
4985 @category{Package distrib}
4991 @anchor{cdf_binomial}
4992 @deffn {Function} cdf_binomial (@var{x},@var{n},@var{p})
4993 Returns the value at @var{x} of the distribution function of a m4_Binomial_RV(n,p) random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer.
4997 <<<F(x; n, p) = I_{1-p}(n-\lfloor x \rfloor, \lfloor x \rfloor + 1)>>>,
5000 F(x, n, p) = beta_incomplete_regularized(n - floor(x), floor(x) + 1,
5005 where m4_math(I_z(a,b)) is the @ref{beta_incomplete_regularized}
5011 @c load ("distrib")$
5012 @c cdf_binomial(5,7,1/6);
5016 (%i1) load ("distrib")$
5018 (%i2) cdf_binomial(5,7,1/6);
5025 (%o3) 0.9998713991769548
5029 @opencatbox{Categories:}
5030 @category{Package distrib}
5036 @anchor{quantile_binomial}
5037 @deffn {Function} quantile_binomial (@var{q},@var{n},@var{p})
5038 Returns the @var{q}-quantile of a m4_Binomial_RV(n,p) random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer; in other words, this is the inverse of @code{cdf_binomial}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
5040 @opencatbox{Categories:}
5041 @category{Package distrib}
5047 @anchor{mean_binomial}
5048 @deffn {Function} mean_binomial (@var{n},@var{p})
5049 Returns the mean of a m4_Binomial_RV(n,p) random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5061 @opencatbox{Categories:}
5062 @category{Package distrib}
5068 @anchor{var_binomial}
5069 @deffn {Function} var_binomial (@var{n},@var{p})
5070 Returns the variance of a m4_Binomial_RV(n,p) random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5074 <<<V[X] = np(1-p)>>>,
5081 @opencatbox{Categories:}
5082 @category{Package distrib}
5088 @anchor{std_binomial}
5089 @deffn {Function} std_binomial (@var{n},@var{p})
5090 Returns the standard deviation of a m4_Binomial_RV(n,p) random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5092 The standard deviation is
5094 <<<D[X] = \sqrt{np(1-p)}>>>,
5097 D[X] = sqrt(n (1 - p) p)
5101 @opencatbox{Categories:}
5102 @category{Package distrib}
5108 @anchor{skewness_binomial}
5109 @deffn {Function} skewness_binomial (@var{n},@var{p})
5110 Returns the skewness coefficient of a m4_Binomial_RV(n,p) random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5112 The skewness coefficient is
5114 <<<SK[X] = {1-2p\over \sqrt{np(1-p)}}>>>,
5118 SK[X] = -----------------
5124 @opencatbox{Categories:}
5125 @category{Package distrib}
5131 @anchor{kurtosis_binomial}
5132 @deffn {Function} kurtosis_binomial (@var{n},@var{p})
5133 Returns the kurtosis coefficient of a m4_Binomial_RV(n,p) random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5135 The kurtosis coefficient is
5137 <<<KU[X] = {1-6p(1-p)\over np(1-p)}>>>,
5141 KU[X] = ---------------
5147 @opencatbox{Categories:}
5148 @category{Package distrib}
5154 @anchor{random_binomial}
5155 @deffn {Function} random_binomial (@var{n},@var{p}) @
5156 @fname{random_binomial} (@var{n},@var{p},@var{m})
5158 Returns a m4_Binomial_RV(n,p) random variate, with @math{0 \leq p \leq 1} and @math{n} a positive integer. Calling @code{random_binomial} with a third argument @var{m}, a random sample of size @var{m} will be simulated.
5160 The implemented algorithm is based on the one described in Kachitvichyanukul, V. and Schmeiser, B.W. (1988) @var{Binomial Random Variate Generation}. Communications of the ACM, 31, Feb., 216.
5162 To make use of this function, write first @code{load("distrib")}.
5164 @opencatbox{Categories:}
5165 @category{Package distrib}
5166 @category{Random numbers}
5171 @node Poisson Random Variable, Bernoulli Random Variable, Binomial Random Variable, Functions and Variables for discrete distributions
5172 @subsection Poisson Random Variable
5174 The @emph{Poisson distribution} is a discrete probability
5175 distribution. It is the probability that a given number of events
5176 occur in a fixed interval when the events occur independently of the
5177 time of the last event, and the events occur with a known constant
5180 @anchor{pdf_poisson}
5181 @deffn {Function} pdf_poisson (@var{x},@var{m})
5182 Returns the value at @var{x} of the probability function of a m4_Poisson_RV(m) random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5186 <<<f(x; m) = {m^x e^{-m}\over x!}>>>,
5197 @opencatbox{Categories:}
5198 @category{Package distrib}
5204 @anchor{cdf_poisson}
5205 @deffn {Function} cdf_poisson (@var{x},@var{m})
5206 Returns the value at @var{x} of the distribution function of a m4_Poisson_RV(m) random variable, with @math{m>0}.
5210 <<<F(x; m) = Q(\lfloor x \rfloor + 1, m)>>>,
5213 F(x, m) = gamma_incomplete_regularized(floor(x) + 1, m)
5217 where @math{Q(x,m)} is the @ref{gamma_incomplete_regularized}
5222 @c load ("distrib")$
5223 @c cdf_poisson(3,5);
5227 (%i1) load ("distrib")$
5229 (%i2) cdf_poisson(3,5);
5230 (%o2) gamma_incomplete_regularized(4, 5)
5234 (%o3) 0.2650259152973619
5238 @opencatbox{Categories:}
5239 @category{Package distrib}
5245 @anchor{quantile_poisson}
5246 @deffn {Function} quantile_poisson (@var{q},@var{m})
5247 Returns the @var{q}-quantile of a m4_Poisson_RV(m) random variable, with @math{m>0}; in other words, this is the inverse of @code{cdf_poisson}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
5249 @opencatbox{Categories:}
5250 @category{Package distrib}
5256 @anchor{mean_poisson}
5257 @deffn {Function} mean_poisson (@var{m})
5258 Returns the mean of a m4_Poisson_RV(m) random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5269 @opencatbox{Categories:}
5270 @category{Package distrib}
5276 @anchor{var_poisson}
5277 @deffn {Function} var_poisson (@var{m})
5278 Returns the variance of a m4_Poisson_RV(m) random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5289 @opencatbox{Categories:}
5290 @category{Package distrib}
5296 @anchor{std_poisson}
5297 @deffn {Function} std_poisson (@var{m})
5298 Returns the standard deviation of a m4_Poisson_RV(m) random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5300 The standard deviation is
5302 <<<V[X] = \sqrt{m}>>>,
5309 @opencatbox{Categories:}
5310 @category{Package distrib}
5316 @anchor{skewness_poisson}
5317 @deffn {Function} skewness_poisson (@var{m})
5318 Returns the skewness coefficient of a m4_Poisson_RV(m) random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5322 <<<SK[X] = {1\over \sqrt{m}}>>>,
5332 @opencatbox{Categories:}
5333 @category{Package distrib}
5339 @anchor{kurtosis_poisson}
5340 @deffn {Function} kurtosis_poisson (@var{m})
5341 Returns the kurtosis coefficient of a Poisson random variable @math{Poi(m)}, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5343 The kurtosis coefficient is
5345 <<<KU[X] = {1\over m}>>>,
5354 @opencatbox{Categories:}
5355 @category{Package distrib}
5361 @anchor{random_poisson}
5362 @deffn {Function} random_poisson (@var{m}) @
5363 @fname{random_poisson} (@var{m},@var{n})
5365 Returns a m4_Poisson_RV(m) random variate, with @math{m>0}. Calling @code{random_poisson} with a second argument @var{n}, a random sample of size @var{n} will be simulated.
5367 The implemented algorithm is the one described in Ahrens, J.H. and Dieter, U. (1982) @var{Computer Generation of Poisson Deviates From Modified Normal Distributions}. ACM Trans. Math. Software, 8, 2, June,163-179.
5369 To make use of this function, write first @code{load("distrib")}.
5371 @opencatbox{Categories:}
5372 @category{Package distrib}
5373 @category{Random numbers}
5378 @node Bernoulli Random Variable, Geometric Random Variable, Poisson Random Variable, Functions and Variables for discrete distributions
5379 @subsection Bernoulli Random Variable
5381 The @emph{Bernoulli distribution} is a discrete probability
5382 distribution which takes on two values, 0 and 1. The value 1 occurs
5383 with probability @math{p}, and 0 occurs with probabilty @math{1-p}.
5385 It is equivalent to the m4_Binomial_RV(1,p) distribution (@pxref{Binomial Random Variable})
5387 @anchor{pdf_bernoulli}
5388 @deffn {Function} pdf_bernoulli (@var{x},@var{p})
5389 Returns the value at @var{x} of the probability function of a m4_Bernoulli_RV(p) random variable, with @math{0 \leq p \leq 1}.
5391 The m4_Bernoulli_RV(p) random variable is equivalent to the m4_Binomial_RV(1,p).
5395 <<<f(x; p) = p^x (1-p)^{1-x}>>>,
5405 @c load ("distrib")$
5406 @c pdf_bernoulli(1,p);
5409 (%i1) load ("distrib")$
5411 (%i2) pdf_bernoulli(1,p);
5416 @opencatbox{Categories:}
5417 @category{Package distrib}
5423 @anchor{cdf_bernoulli}
5424 @deffn {Function} cdf_bernoulli (@var{x},@var{p})
5425 Returns the value at @var{x} of the distribution function of a m4_Bernoulli_RV(p) random variable, with @math{0 \leq p \leq 1}. To make use of this function, write first @code{load("distrib")}.
5429 <<<F(x; p) = I_{1-p}(1-\lfloor x \rfloor, \lfloor x \rfloor + 1)>>>,
5432 F(x, n, p) = beta_incomplete_regularized(n - floor(x), floor(x) + 1,
5438 @opencatbox{Categories:}
5439 @category{Package distrib}
5445 @anchor{quantile_bernoulli}
5446 @deffn {Function} quantile_bernoulli (@var{q},@var{p})
5447 Returns the @var{q}-quantile of a m4_Bernoulli_RV(p) random variable, with @math{0 \leq p \leq 1}; in other words, this is the inverse of @code{cdf_bernoulli}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
5449 @opencatbox{Categories:}
5450 @category{Package distrib}
5456 @anchor{mean_bernoulli}
5457 @deffn {Function} mean_bernoulli (@var{p})
5458 Returns the mean of a m4_Bernoulli_RV(p) random variable, with @math{0 \leq p \leq 1}.
5460 The m4_Bernoulli_RV(p) random variable is equivalent to the m4_Binomial_RV(1,p).
5472 @c load ("distrib")$
5473 @c mean_bernoulli(p);
5476 (%i1) load ("distrib")$
5478 (%i2) mean_bernoulli(p);
5483 @opencatbox{Categories:}
5484 @category{Package distrib}
5490 @anchor{var_bernoulli}
5491 @deffn {Function} var_bernoulli (@var{p})
5492 Returns the variance of a m4_Bernoulli_RV(p) random variable, with @math{0 \leq p \leq 1}.
5494 The m4_Bernoulli_RV(p) random variable is equivalent to the m4_Binomial_RV(1,p).
5498 <<<V[X] = p(1-p)>>>,
5506 @c load ("distrib")$
5507 @c var_bernoulli(p);
5510 (%i1) load ("distrib")$
5512 (%i2) var_bernoulli(p);
5517 @opencatbox{Categories:}
5518 @category{Package distrib}
5524 @anchor{std_bernoulli}
5525 @deffn {Function} std_bernoulli (@var{p})
5526 Returns the standard deviation of a m4_Bernoulli_RV(p) random variable, with @math{0 \leq p \leq 1}.
5528 The m4_Bernoulli_RV(p) random variable is equivalent to the m4_Binomial_RV(1,p).
5530 The standard deviation is
5532 <<<D[X] = \sqrt{p(1-p)}>>>,
5535 D[X] = sqrt((1 - p) p)
5541 @c load ("distrib")$
5542 @c std_bernoulli(p);
5545 (%i1) load ("distrib")$
5547 (%i2) std_bernoulli(p);
5548 (%o2) sqrt((1 - p) p)
5552 @opencatbox{Categories:}
5553 @category{Package distrib}
5559 @anchor{skewness_bernoulli}
5560 @deffn {Function} skewness_bernoulli (@var{p})
5561 Returns the skewness coefficient of a m4_Bernoulli_RV(p) random variable, with @math{0 \leq p \leq 1}.
5563 The m4_Bernoulli_RV(p) random variable is equivalent to the m4_Binomial_RV(1,p).
5565 The skewness coefficient is
5567 <<<SK[X] = {1-2p \over \sqrt{p(1-p)}}>>>,
5571 SK[X] = ---------------
5578 @c load ("distrib")$
5579 @c skewness_bernoulli(p);
5582 (%i1) load ("distrib")$
5584 (%i2) skewness_bernoulli(p);
5586 (%o2) ---------------
5591 @opencatbox{Categories:}
5592 @category{Package distrib}
5598 @anchor{kurtosis_bernoulli}
5599 @deffn {Function} kurtosis_bernoulli (@var{p})
5600 Returns the kurtosis coefficient of a m4_Bernoulli_RV(p) random variable, with @math{0 \leq p \leq 1}.
5602 The m4_Bernoulli_RV(p) random variable is equivalent to the m4_Binomial_RV(1,p).
5604 The kurtosis coefficient is
5606 <<<KU[X] = {1-6p(1-p) \over p(1-p)}>>>,
5610 KU[X] = ---------------
5617 @c load ("distrib")$
5618 @c kurtosis_bernoulli(p);
5621 (%i1) load ("distrib")$
5623 (%i2) kurtosis_bernoulli(p);
5625 (%o2) ---------------
5630 @opencatbox{Categories:}
5631 @category{Package distrib}
5637 @anchor{random_bernoulli}
5638 @deffn {Function} random_bernoulli (@var{p}) @
5639 @fname{random_bernoulli} (@var{p},@var{n})
5641 Returns a m4_Bernoulli_RV(p) random variate, with @math{0 \leq p \leq 1}. Calling @code{random_bernoulli} with a second argument @var{n}, a random sample of size @var{n} will be simulated.
5643 This is a direct application of the @code{random} built-in Maxima function.
5645 See also @mrefdot{random} To make use of this function, write first @code{load("distrib")}.
5647 @opencatbox{Categories:}
5648 @category{Package distrib}
5649 @category{Random numbers}
5654 @node Geometric Random Variable, Discrete Uniform Random Variable, Bernoulli Random Variable, Functions and Variables for discrete distributions
5655 @subsection Geometric Random Variable
5657 The @emph{Geometric distibution} is a discrete probability
5658 distribution. It is the distribution of the number
5659 Bernoulli trials that fail before the first success.
5661 Consider flipping a biased coin where heads occurs with probablity
5662 @math{p}. Then the probability of @math{k-1} tails in a row followed
5663 by heads is given by the m4_Geometric_RV(p) distribution.
5665 @anchor{pdf_geometric}
5666 @deffn {Function} pdf_geometric (@var{x},@var{p})
5667 Returns the value at @var{x} of the probability function of a m4_Geometric_RV(p) random variable, with
5672 <<<f(x; p) = p(1-p)^x>>>,
5681 This is interpreted as the probability of @math{x} failures before the first success.
5683 @code{load("distrib")} loads this function.
5685 @opencatbox{Categories:}
5686 @category{Package distrib}
5692 @anchor{cdf_geometric}
5693 @deffn {Function} cdf_geometric (@var{x},@var{p})
5694 Returns the value at @var{x} of the distribution function of a m4_Geometric_RV(p) random variable, with
5699 <<<1-(1-p)^{1 + \lfloor x \rfloor}>>>,
5703 F(x, p) = 1 - (1 - p)
5708 @code{load("distrib")} loads this function.
5710 @opencatbox{Categories:}
5711 @category{Package distrib}
5717 @anchor{quantile_geometric}
5718 @deffn {Function} quantile_geometric (@var{q},@var{p})
5719 Returns the @var{q}-quantile of a m4_Geometric_RV(p) random variable, with
5724 @math{0 < p \leq 1};
5726 in other words, this is the inverse of @code{cdf_geometric}.
5727 Argument @var{q} must be an element of @math{[0,1]}.
5729 The probability from which the quantile is derived is defined as @math{p (1 - p)^x}.
5730 This is interpreted as the probability of @math{x} failures before the first success.
5732 @code{load("distrib")} loads this function.
5734 @opencatbox{Categories:}
5735 @category{Package distrib}
5741 @anchor{mean_geometric}
5742 @deffn {Function} mean_geometric (@var{p})
5743 Returns the mean of a m4_Geometric_RV(p) random variable, with
5744 @math{0 < p \leq 1}.
5748 <<<E[X] = {1\over p} - 1>>>,
5758 The probability from which the mean is derived is defined as @math{p (1 - p)^x}.
5759 This is interpreted as the probability of @math{x} failures before the first success.
5761 @code{load("distrib")} loads this function.
5763 @opencatbox{Categories:}
5764 @category{Package distrib}
5770 @anchor{var_geometric}
5771 @deffn {Function} var_geometric (@var{p})
5772 Returns the variance of a m4_Geometric_RV(p) random variable, with
5773 @math{0 < p \leq 1}.
5777 <<<V[X] = {1-p\over p^2}>>>,
5788 @code{load("distrib")} loads this function.
5790 @opencatbox{Categories:}
5791 @category{Package distrib}
5797 @anchor{std_geometric}
5798 @deffn {Function} std_geometric (@var{p})
5799 Returns the standard deviation of a m4_Geometric_RV(p) random variable, with
5800 @math{0 < p \leq 1}.
5803 <<<D[X] = {\sqrt{1-p} \over p}>>>,
5813 @code{load("distrib")} loads this function.
5815 @opencatbox{Categories:}
5816 @category{Package distrib}
5822 @anchor{skewness_geometric}
5823 @deffn {Function} skewness_geometric (@var{p})
5824 Returns the skewness coefficient of a m4_Geometric_RV(p) random variable, with
5825 @math{0 < p \leq 1}.
5827 The skewness coefficient is
5829 <<<SK[X] = {2-p \over \sqrt{1-p}}>>>,
5839 @code{load("distrib")} loads this function.
5841 @opencatbox{Categories:}
5842 @category{Package distrib}
5848 @anchor{kurtosis_geometric}
5849 @deffn {Function} kurtosis_geometric (@var{p})
5850 Returns the kurtosis coefficient of a geometric random variable m4_Geometric_RV(p), with
5851 @math{0 < p \leq 1}.
5853 The kurtosis coefficient is
5855 <<<KU[X] = {p^2-6p+6 \over 1-p}>>>,
5860 KU[X] = ------------
5866 @code{load("distrib")} loads this function.
5868 @opencatbox{Categories:}
5869 @category{Package distrib}
5875 @anchor{random_geometric}
5876 @deffn {Function} random_geometric (@var{p}) @
5877 @fname{random_geometric} (@var{p},@var{n})
5879 @code{random_geometric(@var{p})} returns one random sample from a m4_Geometric_RV(p) distribution, with
5884 @math{0 < p \leq 1}.
5887 @code{random_geometric(@var{p}, @var{n})} returns a list of @var{n} random samples.
5889 The algorithm is based on simulation of Bernoulli trials.
5891 The probability from which the random sample is derived is defined as @math{p (1 - p)^x}.
5892 This is interpreted as the probability of @math{x} failures before the first success.
5894 @code{load("distrib")} loads this function.
5897 @opencatbox{Categories:}
5898 @category{Package distrib}
5899 @category{Random numbers}
5904 @node Discrete Uniform Random Variable, Hypergeometric Random Variable, Geometric Random Variable, Functions and Variables for discrete distributions
5905 @subsection Discrete Uniform Random Variable
5907 The @emph{Discrete uniform distribution} is a discrete probablity
5908 distribution where a finite number of values are equally likely to
5909 occur. The values are @math{1,2,3,...,n}.
5911 For example throwing a fair die of 6 sides numbered 1 through 6
5912 follows a m4_DiscreteUniform_RV(1/6) distribution.
5914 @anchor{pdf_discrete_uniform}
5915 @deffn {Function} pdf_discrete_uniform (@var{x},@var{n})
5916 Returns the value at @var{x} of the probability function of a m4_DiscreteUniform_RV(n) random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
5920 <<<f(x,n) = {1\over n}>>>,
5930 @opencatbox{Categories:}
5931 @category{Package distrib}
5937 @anchor{cdf_discrete_uniform}
5938 @deffn {Function} cdf_discrete_uniform (@var{x},@var{n})
5939 Returns the value at @var{x} of the distribution function of a m4_DiscreteUniform_RV(n) random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
5943 <<<F(x; n) = {\lfloor x \rfloor \over n}>>>,
5953 @opencatbox{Categories:}
5954 @category{Package distrib}
5960 @anchor{quantile_discrete_uniform}
5961 @deffn {Function} quantile_discrete_uniform (@var{q},@var{n})
5962 Returns the @var{q}-quantile of a m4_DiscreteUniform_RV(n) random variable, with @math{n} a strictly positive integer; in other words, this is the inverse of @code{cdf_discrete_uniform}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
5964 @opencatbox{Categories:}
5965 @category{Package distrib}
5971 @anchor{mean_discrete_uniform}
5972 @deffn {Function} mean_discrete_uniform (@var{n})
5973 Returns the mean of a m4_DiscreteUniform_RV(n) random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
5977 <<<E[X] = {n+1\over 2}>>>,
5987 @opencatbox{Categories:}
5988 @category{Package distrib}
5994 @anchor{var_discrete_uniform}
5995 @deffn {Function} var_discrete_uniform (@var{n})
5996 Returns the variance of a m4_DiscreteUniform_RV(n) random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6000 <<<V[X] = {n^2-1 \over 12}>>>,
6011 @opencatbox{Categories:}
6012 @category{Package distrib}
6018 @anchor{std_discrete_uniform}
6019 @deffn {Function} std_discrete_uniform (@var{n})
6020 Returns the standard deviation of a m4_DiscreteUniform_RV(n) random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6022 The standard deviation is
6024 <<<D[X] = {\sqrt{n^2-1} \over 2\sqrt{3}}>>>,
6035 @opencatbox{Categories:}
6036 @category{Package distrib}
6042 @anchor{skewness_discrete_uniform}
6043 @deffn {Function} skewness_discrete_uniform (@var{n})
6044 Returns the skewness coefficient of a m4_DiscreteUniform_RV(n) random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6046 The skewness coefficient is
6055 @opencatbox{Categories:}
6056 @category{Package distrib}
6062 @anchor{kurtosis_discrete_uniform}
6063 @deffn {Function} kurtosis_discrete_uniform (@var{n})
6064 Returns the kurtosis coefficient of a m4_DiscreteUniform_RV(n) random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6066 The kurtosis coefficient is
6068 <<<KU[X] = - {6(n^2+1)\over 5 (n^2-1)}>>>,
6073 KU[X] = - -----------------
6079 @opencatbox{Categories:}
6080 @category{Package distrib}
6086 @anchor{random_discrete_uniform}
6087 @deffn {Function} random_discrete_uniform (@var{n}) @
6088 @fname{random_discrete_uniform} (@var{n},@var{m})
6090 Returns a m4_DiscreteUniform_RV(n) random variate, with @math{n} a strictly positive integer. Calling @code{random_discrete_uniform} with a second argument @var{m}, a random sample of size @var{m} will be simulated.
6092 This is a direct application of the @code{random} built-in Maxima function.
6094 See also @mrefdot{random} To make use of this function, write first @code{load("distrib")}.
6096 @opencatbox{Categories:}
6097 @category{Package distrib}
6098 @category{Random numbers}
6103 @node Hypergeometric Random Variable, Negative Binomial Random Variable, Discrete Uniform Random Variable, Functions and Variables for discrete distributions
6104 @subsection Hypergeometric Random Variable
6106 The @emph{hypergeometric distribution} is a discrete probability
6109 Let @math{n_1} be the number of objects of a class
6110 @math{A} and @math{n_2} be the number of objects of class @math{B}.
6111 We take out @math{n} objects, @emph{without} replacment. Then the
6112 hypergeometric distribution is the probability that exactly @math{k}
6113 objects are from class @math{A}. Of course @math{n \leq n_1 + n_2}.
6115 @anchor{pdf_hypergeometric}
6116 @deffn {Function} pdf_hypergeometric (@var{x},@var{n_1},@var{n_2},@var{n})
6117 Returns the value at @var{x} of the probability function of a m4_Hypergeometric_RV(n1,n2,n)
6118 random variable, with @math{n_1}, @math{n_2} and @math{n} non negative
6119 integers and @math{n\leq n_1+n_2}.
6120 Being @math{n_1} the number of objects of class A, @math{n_2} the number of objects of class B, and
6121 @math{n} the size of the sample without replacement, this function returns the probability of
6122 event "exactly @var{x} objects are of class A".
6124 To make use of this function, write first @code{load("distrib")}.
6128 <<<f(x; n_1, n_2, n) = {\displaystyle{n_1\choose x} {n_2 \choose n-x}
6129 \over \displaystyle{n_2+n_1 \choose n}}>>>,
6132 binomial(n_1, x) binomial(n_2, n - x)
6133 f(x, n_1, n_2, n) = -----------------------------------
6134 binomial(n_2 + n_1, n)
6139 @opencatbox{Categories:}
6140 @category{Package distrib}
6146 @anchor{cdf_hypergeometric}
6147 @deffn {Function} cdf_hypergeometric (@var{x},@var{n_1},@var{n_2},@var{n})
6148 Returns the value at @var{x} of the distribution function of a m4_Hypergeometric_RV(n1,n2,n)
6149 random variable, with @math{n_1}, @math{n_2} and @math{n} non negative
6150 integers and @math{n\leq n_1+n_2}.
6151 See @code{pdf_hypergeometric} for a more complete description.
6153 To make use of this function, write first @code{load("distrib")}.
6157 <<<F(x; n_1, n_2, n) = {n_2+n_1\choose n}^{-1}
6158 \sum_{k=0}^{\lfloor x \rfloor} {n_1 \choose k} {n_2 \choose n - k}>>>,
6164 > binomial(n_1, k) binomial(n_2, n - k)
6168 F(x, n_1, n_2, n) = --------------------------------------------
6169 binomial(n_2 + n_1, n)
6174 @opencatbox{Categories:}
6175 @category{Package distrib}
6181 @anchor{quantile_hypergeometric}
6182 @deffn {Function} quantile_hypergeometric (@var{q},@var{n1},@var{n2},@var{n})
6183 Returns the @var{q}-quantile of a m4_Hypergeometric_RV(n1,n2,n) random
6184 variable, with @var{n1}, @var{n2} and @var{n} non negative integers
6185 and @math{n\leq n1+n2}; in other words, this is the inverse of @code{cdf_hypergeometric}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
6187 @opencatbox{Categories:}
6188 @category{Package distrib}
6194 @anchor{mean_hypergeometric}
6195 @deffn {Function} mean_hypergeometric (@var{n_1},@var{n_2},@var{n})
6196 Returns the mean of a discrete uniform random variable m4_Hypergeometric_RV(n_1,n_2,n), with @math{n_1}, @math{n_2} and @math{n} non negative integers and @math{n\leq n_1+n_2}. To make use of this function, write first @code{load("distrib")}.
6200 <<<E[X] = {n n_1\over n_2+n_1}>>>,
6211 @opencatbox{Categories:}
6212 @category{Package distrib}
6218 @anchor{var_hypergeometric}
6219 @deffn {Function} var_hypergeometric (@var{n1},@var{n2},@var{n})
6220 Returns the variance of a hypergeometric random variable m4_Hypergeometric_RV(n_1,n_2,n), with @math{n1}, @math{n2} and @math{n} non negative integers and @math{n<=n1+n2}. To make use of this function, write first @code{load("distrib")}.
6224 <<<V[X] = {n n_1 n_2 (n_1 + n_2 - n)
6226 (n_1 + n_2 - 1) (n_1 + n_2)^2}>>>,
6229 n n_1 n_2 (n_2 + n_1 - n)
6230 V[X] = ----------------------------
6232 (n_2 + n_1 - 1) (n_2 + n_1)
6237 @opencatbox{Categories:}
6238 @category{Package distrib}
6244 @anchor{std_hypergeometric}
6245 @deffn {Function} std_hypergeometric (@var{n_1},@var{n_2},@var{n})
6246 Returns the standard deviation of a m4_Hypergeometric_RV(n_1,n_2,n) random variable, with @math{n_1}, @math{n_2} and @math{n} non negative integers and @math{n\leq n_1+n_2}. To make use of this function, write first @code{load("distrib")}.
6248 The standard deviation is
6250 <<<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}>>>,
6253 n n_1 n_2 (n_2 + n_1 - n)
6254 sqrt(-------------------------)
6256 D[X] = -------------------------------
6262 @opencatbox{Categories:}
6263 @category{Package distrib}
6269 @anchor{skewness_hypergeometric}
6270 @deffn {Function} skewness_hypergeometric (@var{n_1},@var{n_2},@var{n})
6271 Returns the skewness coefficient of a m4_Hypergeometric_RV(n1,n2,n) random variable, with @math{n_1}, @math{n_2} and @math{n} non negative integers and @math{n\leq n1+n2}. To make use of this function, write first @code{load("distrib")}.
6273 The skewness coefficient is
6275 <<<SK[X] = {(n_2-n_2)(n_1+n_2-2n)\over n_1+n_2-2}
6276 \sqrt{n_1+n_2-1 \over n n_1 n_2 (n_1+n_2-n)}>>>,
6280 (n_2 - n_1) (n_2 + n_1 - 2 n) sqrt(-------------------------)
6281 n n_1 n_2 (n_2 + n_1 - n)
6282 SK[X] = -------------------------------------------------------------
6289 @opencatbox{Categories:}
6290 @category{Package distrib}
6296 @anchor{kurtosis_hypergeometric}
6297 @deffn {Function} kurtosis_hypergeometric (@var{n_1},@var{n_2},@var{n})
6298 Returns the kurtosis coefficient of a m4_Hypergeometric_RV(n_1,n_2,n) random variable, with @math{n_1}, @math{n_2} and @math{n} non negative integers and @math{n\leq n1+n2}. To make use of this function, write first @code{load("distrib")}.
6300 The kurtosis coefficient is
6307 n n_1 n_2 C(3)C(2)C(n)}\right. \cr
6310 {3n_1n_2\left((n-2)C(0)^2+6nC(n)-n^2C(0)\right)
6321 KU[X] = ((n_2 + n_1 - 1) (n_2 + n_1)
6323 3 n_1 n_2 ((n - 2) (n_2 + n_1) + 6 n (n_2 + n_1 - n) - n (n_2 + n_1))
6324 (-----------------------------------------------------------------------
6327 - 6 n (n_2 + n_1 - n) + (n_2 + n_1) (n_2 + n_1 + 1)))
6328 /(n n_1 n_2 (n_2 + n_1 - 3) (n_2 + n_1 - 2) (n_2 + n_1 - n)) - 3
6332 where m4_math(C(k) = n_1+n_2-k).
6335 @opencatbox{Categories:}
6336 @category{Package distrib}
6342 @anchor{random_hypergeometric}
6343 @deffn {Function} random_hypergeometric (@var{n1},@var{n2},@var{n}) @
6344 @fname{random_hypergeometric} (@var{n1},@var{n2},@var{n},@var{m})
6346 Returns a m4_Hypergeometric_RV(n1,n2,n) random variate, with @var{n1}, @var{n2} and @var{n} non negative integers and @math{n<=n1+n2}. Calling @code{random_hypergeometric} with a fourth argument @var{m}, a random sample of size @var{m} will be simulated.
6348 Algorithm described in Kachitvichyanukul, V., Schmeiser, B.W. (1985) @var{Computer generation of hypergeometric random variates.} Journal of Statistical Computation and Simulation 22, 127-145.
6350 To make use of this function, write first @code{load("distrib")}.
6352 @opencatbox{Categories:}
6353 @category{Package distrib}
6354 @category{Random numbers}
6359 @node Negative Binomial Random Variable, , Hypergeometric Random Variable, Functions and Variables for discrete distributions
6360 @subsection Negative Binomial Random Variable
6362 The @emph{negative binomial distribution} is a discrete probability
6363 distribution. Suppose we have a sequence of Bernoulli trials where
6364 each trial has two outcomes called ``success'' and ``failure'' where
6365 ``success'' occurs with probablity @math{p} and ``failure'' with
6366 probability @math{1-p}. We observe the sequence until a predefined
6367 number @math{r} of sucesses have occurred. Then the number of
6368 failures seen will have a m4_NegativeBinomial_RV(r, p) distribution.
6370 @anchor{pdf_negative_binomial}
6371 @deffn {Function} pdf_negative_binomial (@var{x},@var{n},@var{p})
6372 Returns the value at @var{x} of the probability function of a m4_NegativeBinomial_RV(n,p) random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
6376 <<<f(x; n, p) = {x+n-1 \choose n-1} (1-p)^xp^n>>>,
6380 (1 - p) p gamma(x + n)
6381 f(x, n, p) = ------------------------
6387 @opencatbox{Categories:}
6388 @category{Package distrib}
6394 @anchor{cdf_negative_binomial}
6395 @deffn {Function} cdf_negative_binomial (@var{x},@var{n},@var{p})
6396 Returns the value at @var{x} of the distribution function of a m4_NegativeBinomial_RV(n,p) random variable, with @math{0 < p \leq 1} and @math{n} a positive number.
6400 <<<F(x; n, p) = I_p(n,\lfloor x \rfloor + 1)>>>,
6403 F(x, n, p) = beta_incomplete_regularized(n, floor(x) + 1, p)
6407 where m4_math(I_p(a,b)) is the @ref{beta_incomplete_regularized} function.
6411 @c load ("distrib")$
6412 @c cdf_negative_binomial(3,4,1/8);
6415 (%i1) load ("distrib")$
6417 (%i2) cdf_negative_binomial(3,4,1/8);
6424 @opencatbox{Categories:}
6425 @category{Package distrib}
6431 @anchor{quantile_negative_binomial}
6432 @deffn {Function} quantile_negative_binomial (@var{q},@var{n},@var{p})
6433 Returns the @var{q}-quantile of a m4_NegativeBinomial_RV(n,p) random variable, with @math{0 < p \leq 1} and @math{n} a positive number; in other words, this is the inverse of @code{cdf_negative_binomial}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
6435 @opencatbox{Categories:}
6436 @category{Package distrib}
6442 @anchor{mean_negative_binomial}
6443 @deffn {Function} mean_negative_binomial (@var{n},@var{p})
6444 Returns the mean of a m4_NegativeBinomial_RV(n,p) random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
6448 <<<E[X] = {n(1-p)\over p}>>>,
6457 @opencatbox{Categories:}
6458 @category{Package distrib}
6464 @anchor{var_negative_binomial}
6465 @deffn {Function} var_negative_binomial (@var{n},@var{p})
6466 Returns the variance of a m4_NegativeBinomial_RV(n,p) random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
6470 <<<V[X] = {n(1-p)\over p^2}>>>,
6480 @opencatbox{Categories:}
6481 @category{Package distrib}
6487 @anchor{std_negative_binomial}
6488 @deffn {Function} std_negative_binomial (@var{n},@var{p})
6489 Returns the standard deviation of a m4_NegativeBinomial_RV(n,p) random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
6491 The standard deviation is
6493 <<<D[X] = {\sqrt{n(1-p)}\over p}>>>,
6497 D[X] = ---------------
6502 @opencatbox{Categories:}
6503 @category{Package distrib}
6509 @anchor{skewness_negative_binomial}
6510 @deffn {Function} skewness_negative_binomial (@var{n},@var{p})
6511 Returns the skewness coefficient of a m4_NegativeBinomial_RV(n,p) random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
6513 The skewness coefficient is
6515 <<<SK[X] = {2-p \over \sqrt{n(1-p)}}>>>,
6519 SK[X] = ---------------
6524 @opencatbox{Categories:}
6525 @category{Package distrib}
6531 @anchor{kurtosis_negative_binomial}
6532 @deffn {Function} kurtosis_negative_binomial (@var{n},@var{p})
6533 Returns the kurtosis coefficient of a m4_NegativeBinomial_RV(n,p) random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
6535 The kurtosis coefficient is
6537 <<<KU[X] = {p^2-6p+6 \over n(1-p)}>>>,
6542 KU[X] = ------------
6548 @opencatbox{Categories:}
6549 @category{Package distrib}
6555 @anchor{random_negative_binomial}
6556 @deffn {Function} random_negative_binomial (@var{n},@var{p}) @
6557 @fname{random_negative_binomial} (@var{n},@var{p},@var{m})
6559 Returns a m4_NegativeBinomial_RV(n,p) random variate, with @math{0 < p \leq 1} and @math{n} a positive number. Calling @code{random_negative_binomial} with a third argument @var{m}, a random sample of size @var{m} will be simulated.
6561 Algorithm described in Devroye, L. (1986) @var{Non-Uniform Random Variate Generation}. Springer Verlag, p. 480.
6563 To make use of this function, write first @code{load("distrib")}.
6565 @opencatbox{Categories:}
6566 @category{Package distrib}
6567 @category{Random numbers}
6571 @c Undefine all the m4 macros we defined in this file.
6572 m4_undefine(<<<m4_Normal_RV>>>)