Random Number Distributions¶
Uniform Distribution¶
-
rand()¶ Generates a random number between \(0\) and \(1\) from the uniform distribution \(U(0, 1)\).
>>> rand() = 0.1629098753910512
Gaussian Distribution¶
-
randn()¶ Generates a random number from the gaussian distribution \(\mathcal{N}(0, 1)\).
The probability distribution for Gaussian random variates is,
\[p(x) dx = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\left( -\frac{x^2}{2\sigma^2} \right) dx\]>>> randn() = 0.1339186081186759
-
gauss_pdf(x, sigma=1)¶ Computes the probability density \(p(x)\) at \(x\) for a Gaussian distribution with standard deviation
sigma, using the formula given above.>>> gauss_pdf(2) = 0.05399096651318806 >>> gauss_pdf(2, 1) = 0.05399096651318806
-
gauss_P(x, sigma=1)¶ Computes the cumulative density \(P(x)\) at \(x\)
\[P(x) = \int_{-\infty}^{x} p(t) dt\]where \(p(t)\) is the gaussian distribution with standard deviation
sigma. Aliases:norm>>> gauss_P(2) = 0.9772498680518208 >>> norm(2, 1) = 0.9772498680518208
-
gauss_Pinv(x, sigma=1)¶ Computes the inverse of the cumulative density \(P^{-1}(x)\) at \(x\) for the gaussian distribution with standard deviation
sigma. Aliases:norminv>>> gauss_Pinv(0.9772498680518208) = 2 >>> norminv(2, 1) = 2
-
gauss_Q(x, sigma=1)¶ Computes the cumulative density \(P(x)\) at \(x\)
\[Q(x) = \int_{x}^{\infty} p(t) dt\]where \(p(t)\) is the gaussian distribution with standard deviation
sigma. Aliases:cnorm>>> gauss_Q(2) = 0.02275013194817921 >>> cnorm(2, 1) = 0.02275013194817921
-
gauss_Qinv(x, sigma=1)¶ Computes the inverse of the cumulative density \(Q^{-1}(x)\) at \(x\) for the gaussian distribution with standard deviation
sigma. Aliases:cnorminv>>> gauss_Qinv(0.02275013194817921) = 2 >>> cnorminv(2, 1) = 2
Exponential Distribution¶
-
exponential(mu)¶ Generates a random number from the exponential distribution with mean
mu.The probability distribution for exponential random variates is,
\[p(x) dx = \frac{1}{\mu} \exp\left( -\frac{x}{\mu} \right) dx\]for \(x \ge 0\)
>>> exponential(1) = 8.261578216370394 >>> exponential(1) = 0.177823538531874
-
exponential_pdf(x, mu)¶ Computes the probability density \(p(x)\) at \(x\) for an exponential distribution with mean
mu, using the formula given above.>>> exponential_pdf(2, 1) = 0.1353352832366127I
-
exponential_P(x, mu)¶ Computes the cumulative density \(P(x)\) at \(x\)
\[P(x) = \int_{-\infty}^{x} p(t) dt\]where \(p(t)\) is the exponential distribution with mean
mu. Aliases:exp_P>>> exponential_P(2, 1) = 0.8646647167633873 >>> exp_P(2, 1) = 0.8646647167633873
-
exponential_Pinv(x, mu)¶ Computes the inverse of the cumulative density \(P^{-1}(x)\) at \(x\) for the exponential distribution with mean
mu. Aliases:exp_Pinv>>> exponential_Pinv(0.8646647167633873, 1) = 2 >>> exp_Pinv(0.8646647167633873, 1) = 2
-
exponential_Q(x, mu)¶ Computes the cumulative density \(P(x)\) at \(x\)
\[Q(x) = \int_{x}^{\infty} p(t) dt\]where \(p(t)\) is the exponential distribution with mean
mu. Aliases:exp_Q>>> exponential_Q(2, 1) = 0.1353352832366127 >>> exp_Q(2, 1) = 0.1353352832366127
-
exponential_Qinv(x, mu)¶ Computes the inverse of the cumulative density \(Q^{-1}(x)\) at \(x\) for the exponential distribution with mean
mu. Aliases:exp_Pinv>>> exponential_Qinv(0.1353352832366127, 1) = 2 >>> exp_Qinv(0.1353352832366127, 1) = 2
Chi-Squared Distribution¶
-
chisq(nu)¶ Generates a random number from the chi-squared distribution with
nudegrees of freedom.The probability distribution for chi-squared random variates is,
\[p(x) dx = \frac{1}{2\Gamma(\nu/2)} (x/2)^{\nu/2-1} \exp\left( -\frac{x}{2} \right) dx\]for \(x \ge 0\)
>>> chisq(1) = 1.915412399185662 >>> chisq(1) = 3.098215236623985
-
chisq_pdf(x, nu)¶ Computes the probability density \(p(x)\) at \(x\) for an chi-squared distribution with
nudegrees of freedom, using the formula given above.>>> chisq_pdf(2, 1) = 0.1037768743551486
-
chisq_P(x, nu)¶ Computes the cumulative density \(P(x)\) at \(x\)
\[P(x) = \int_{-\infty}^{x} p(t) dt\]where \(p(t)\) is the chi-squared distribution with
nudegrees of freedom.>>> chisq_P(2, 1) = 0.842700792949715 >>> chisq_P(2, 2) = 0.6321205588285578
-
chisq_Pinv(x, nu)¶ Computes the inverse of the cumulative density \(P^{-1}(x)\) at \(x\) for the chi-squared distribution with
nudegrees of freedom.>>> chisq_Pinv(0.842700792949715, 1) = 2 >>> chisq_Pinv(0.6321205588285578, 2) = 2
-
chisq_Q(x, nu)¶ Computes the cumulative density \(P(x)\) at \(x\)
\[Q(x) = \int_{x}^{\infty} p(t) dt\]where \(p(t)\) is the chi-squared distribution with
nudegrees of freedom.>>> chisq_Q(2, 1) = 0.157299207050285 >>> chisq_Q(2, 2) = 0.3678794411714423
-
chisq_Qinv(x, nu)¶ Computes the inverse of the cumulative density \(Q^{-1}(x)\) at \(x\) for the chi-squared distribution with
nudegrees of freedom.>>> chisq_Qinv(0.157299207050285, 1) = 2 >>> chisq_Qinv(0.3678794411714423, 2) = 2