Distributions beyond numpy.random, mostly from scipy.stats.
- Source:
Classes
Methods
(static) betaBinomial(n, a, b, sizeopt) → {number|Array}
Draws samples from the beta-binomial distribution: binomial with a Beta(a, b) success probability.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
n |
number | Number of trials (non-negative integer). |
||
a |
number | Alpha (> 0). |
||
b |
number | Beta (> 0). |
||
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) betaPrime(a, b, sizeopt) → {number|Array}
Draws samples from the beta prime (beta of the second kind) distribution.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
a |
number | Shape (> 0). |
||
b |
number | Shape (> 0). |
||
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) burr12(c, d, scaleopt, sizeopt) → {number|Array}
Draws samples from the Burr type XII (Singh–Maddala) distribution, CDF 1 - (1 + x^c)^-d.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
c |
number | Shape (> 0). |
||
d |
number | Shape (> 0). |
||
scale |
number |
<optional> |
1 | Scale (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) categorical(p, sizeopt) → {number|Array}
Draws category indices 0..k-1 with the given probabilities (or non-negative weights). Uses Walker's alias method: O(k) setup, O(1) per sample.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
p |
Array.<number> | Probabilities or weights of each category. |
||
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) chi(df, sizeopt) → {number|Array}
Draws samples from the chi distribution (square root of a chi-square variable).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
df |
number | Degrees of freedom (> 0). |
||
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) erlang(k, rateopt, sizeopt) → {number|Array}
Draws samples from the Erlang distribution: the sum of k exponential variables with rate rate.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
k |
number | Shape (positive integer). |
||
rate |
number |
<optional> |
1 | Rate (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) exGaussian(muopt, sigmaopt, lambdaopt, sizeopt) → {number|Array}
Draws samples from the exponentially modified Gaussian (ex-Gaussian) distribution: N(mu, sigma²) + Exponential(rate lambda).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
mu |
number |
<optional> |
0 | Mean of the normal component. |
sigma |
number |
<optional> |
1 | Standard deviation of the normal component (> 0). |
lambda |
number |
<optional> |
1 | Rate of the exponential component (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) frechet(alpha, scaleopt, locopt, sizeopt) → {number|Array}
Draws samples from the Fréchet (inverse Weibull, type II extreme value) distribution.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
alpha |
number | Shape (> 0). |
||
scale |
number |
<optional> |
1 | Scale (> 0). |
loc |
number |
<optional> |
0 | Location (minimum). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) generalizedExtremeValue(xiopt, locopt, scaleopt, sizeopt) → {number|Array}
Draws samples from the generalized extreme value distribution with shape xi
(xi > 0 Fréchet type, xi = 0 Gumbel, xi < 0 reversed Weibull). Note scipy's
genextreme uses c = -xi.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
xi |
number |
<optional> |
0 | Shape. |
loc |
number |
<optional> |
0 | Location. |
scale |
number |
<optional> |
1 | Scale (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) generalizedPareto(xiopt, locopt, scaleopt, sizeopt) → {number|Array}
Draws samples from the generalized Pareto distribution (peaks over threshold).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
xi |
number |
<optional> |
0 | Shape; 0 gives the exponential distribution. |
loc |
number |
<optional> |
0 | Location (threshold). |
scale |
number |
<optional> |
1 | Scale (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) halfNormal(scaleopt, locopt, sizeopt) → {number|Array}
Draws samples from the half-normal distribution |N(0, scale²)|, shifted by loc.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
scale |
number |
<optional> |
1 | Scale (> 0). |
loc |
number |
<optional> |
0 | Location. |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) inverseGamma(shape, scaleopt, sizeopt) → {number|Array}
Draws samples from the inverse gamma distribution.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
shape |
number | Shape (> 0). |
||
scale |
number |
<optional> |
1 | Scale (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) kumaraswamy(a, b, sizeopt) → {number|Array}
Draws samples from the Kumaraswamy distribution on [0, 1], CDF 1 - (1 - x^a)^b.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
a |
number | Shape (> 0). |
||
b |
number | Shape (> 0). |
||
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) levy(locopt, scaleopt, sizeopt) → {number|Array}
Draws samples from the Lévy distribution (stable with alpha = 1/2).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
loc |
number |
<optional> |
0 | Location. |
scale |
number |
<optional> |
1 | Scale (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) logLogistic(c, scaleopt, sizeopt) → {number|Array}
Draws samples from the log-logistic (Fisk) distribution, CDF 1 / (1 + (x/scale)^-c).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
c |
number | Shape (> 0). |
||
scale |
number |
<optional> |
1 | Scale / median (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) loguniform(low, high, sizeopt) → {number|Array}
Draws samples from the log-uniform (reciprocal) distribution on [low, high]: log(X) is uniform on [log(low), log(high)].
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
low |
number | Lower bound (> 0). |
||
high |
number | Upper bound (> low). |
||
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) maxwell(scaleopt, sizeopt) → {number|Array}
Draws samples from the Maxwell–Boltzmann distribution.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
scale |
number |
<optional> |
1 | Scale (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) nakagami(m, omegaopt, sizeopt) → {number|Array}
Draws samples from the Nakagami-m distribution.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
m |
number | Shape (>= 0.5). |
||
omega |
number |
<optional> |
1 | Spread, E[X²] (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) rademacher(sizeopt) → {number|Array}
Draws samples from the Rademacher distribution: -1 or 1 with equal probability.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) semicircle(radiusopt, sizeopt) → {number|Array}
Draws samples from the Wigner semicircle distribution on [-radius, radius].
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
radius |
number |
<optional> |
1 | Radius (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) skellam(mu1, mu2, sizeopt) → {number|Array}
Draws samples from the Skellam distribution: the difference of two independent Poisson variables.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
mu1 |
number | Mean of the first Poisson variable (>= 0). |
||
mu2 |
number | Mean of the second Poisson variable (>= 0). |
||
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) skewNormal(locopt, scaleopt, shapeopt, sizeopt) → {number|Array}
Draws samples from the skew-normal distribution (Azzalini).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
loc |
number |
<optional> |
0 | Location. |
scale |
number |
<optional> |
1 | Scale (> 0). |
shape |
number |
<optional> |
0 | Skewness parameter alpha; 0 gives the normal distribution. |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
(static) truncatedNormal(locopt, scaleopt, lowopt, highopt, sizeopt) → {number|Array}
Draws samples from a normal distribution truncated to [low, high]. Exact and efficient for every interval, including far tails (Robert's mixed rejection algorithm), where naive rejection or inverse-CDF methods fail.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
loc |
number |
<optional> |
0 | Mean of the parent normal distribution. |
scale |
number |
<optional> |
1 | Standard deviation of the parent normal distribution (> 0). |
low |
number |
<optional> |
-Infinity | Lower bound. |
high |
number |
<optional> |
Infinity | Upper bound (> low). |
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- number | Array
Example
truncatedNormal(0, 1, 0, Infinity) // half-normal
truncatedNormal(0, 1, 8, 9) // deep tail, still fast and exact
(static) uniformBall(dimopt, radiusopt, sizeopt) → {Array.<number>|Array}
Draws points uniformly distributed inside the ball of the given radius in dim dimensions.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dim |
number |
<optional> |
3 | Dimension (positive integer). |
radius |
number |
<optional> |
1 | Radius (> 0). |
size |
number | Array | null |
<optional> |
null | Output shape (each element is a vector). |
- Source:
Returns:
- Type
- Array.<number> | Array
(static) uniformSphere(dimopt, sizeopt) → {Array.<number>|Array}
Draws points uniformly distributed on the surface of the unit sphere in dim dimensions
(random directions / unit vectors).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dim |
number |
<optional> |
3 | Dimension (positive integer). |
size |
number | Array | null |
<optional> |
null | Output shape (each element is a vector). |
- Source:
Returns:
- Type
- Array.<number> | Array
(static) uuid4(sizeopt) → {string|Array}
Generates RFC 4122 version 4 (random) UUID strings.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
size |
number | Array | null |
<optional> |
null | Output shape. |
- Source:
Returns:
- Type
- string | Array
(inner) truncatedTail()
Truncated standard normal on [a, b] with 0 <= a < b (Robert, 1995/2009).
- Source: