gamrnd
Builtin index · Statistics & ML
result = gamrnd(a, b, [rows], [cols], [seed=])
Input: a, b, rows, cols, seed · Output: result
What it is
Random draws from the gamma distribution. Every parameter is required here (the size follows them); rows/cols and seed= work as for rand, and seed(n) governs unseeded calls.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = gamrnd(a, b, [rows], [cols], [seed=]) | a number, vector, or matrixReturns a number, vector or (rows, cols) matrix.b —not documented yetrows optionalrows/cols and seed= work as for rand, and seed(n) governs unseeded calls.cols optionalrows/cols and seed= work as for rand, and seed(n) governs unseeded calls.seed optionalrows/cols and seed= work as for rand, and seed(n) governs unseeded calls. | result number, vector, or matrix | Returns a number, vector or (rows, cols) matrix. Added in v0.4.4. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
print("geo = nbin(r=1): {geopdf(3, 0.2)} {nbinpdf(3, 1, 0.2)}")
print("bern = bino(n=1): {bernpdf(1, 0.3)} {binopdf(1, 1, 0.3)}")
print("chi2 = gam(k/2, 2): {chi2cdf(4.5, 3)} {gamcdf(4.5, 1.5, 2)}")
print("exp = gam(1, mu): {expcdf(2, 3)} {gamcdf(2, 1, 3)}")
print("bino -> poiss: {binocdf(3, 10000, 0.0004)} vs {poisscdf(3, 4)}")
s = hygestat(50, 10, 12)
print("hypergeometric mean {s.mean}, variance {round(s.var, 4)}")
x = gamrnd(2.5, 1.5, 5000, 1, seed = 7)
g = gamfit(x)
print("gamfit: a = {round(g.a, 2)}, b = {round(g.b, 2)}, loglik = {round(g.loglik, 1)}")
k = binoinv(0.95, 20, 0.3)
print("95% of Binomial(20, 0.3) draws are <= {k}: binocdf = {round(binocdf(k, 20, 0.3), 4)}")
output
geo = nbin(r=1): 0.1024 0.1024 bern = bino(n=1): 0.3 0.3 chi2 = gam(k/2, 2): 0.78771 0.78771 exp = gam(1, mu): 0.486583 0.486583 bino -> poiss: 0.433431 vs 0.43347 hypergeometric mean 2.4, variance 1.489 gamfit: a = 2.55, b = 1.47, loglik = -10647.1 95% of Binomial(20, 0.3) draws are <= 9: binocdf = 0.952
from statistics-ml