# `•distribution` — Distributions

`params •distribution name` returns the distribution called `name`, with parameters `params`. `•distribution name` uses the distribution's standard parameters, listed in the table below. A distribution is a keyed vector of four functions:

- `sample shape` draws random values from the session's generator, as [`¿`](../glyphs/inverted-question.md) does. `g sample shape` draws them from `g`, a generator made by `•rand`.
- `density x` gives the probability density, or the probability mass for a discrete distribution.
- `cdf x` gives P(X ≤ x).
- `quantile p` inverts the CDF. `cdf⁻` is `quantile`, and `quantile⁻` is `cdf`.

```bpl
d←•distribution "normal"
d.cdf 0                         ⍝ 0.5
b←10 0.5 •distribution "binomial"
b.quantile 0.5                  ⍝ 5ₓ
```

Parameters are finite real units or vectors. Scale, shape, rate and degrees of freedom are positive, except where the table says otherwise. [Distributions](../distributions.md) shows distributions in use.

| Name | Parameters | Standard |
|--- |--- |--- |
| `"normal"` | μ σ: mean, standard deviation | 0 1 |
| `"uniform"` | a b: lower and upper bounds, a \< b | 0 1 |
| `"bernoulli"` | p ∈ \[0,1\] |  |
| `"binomial"` | n p: integer trials n ≥ 0, p ∈ \[0,1\] |  |
| `"poisson"` | λ ≥ 0: mean |  |
| `"beta"` | α β: shapes |  |
| `"gamma"` | k θ: shape, scale, with mean kθ |  |
| `"inversegamma"` | α β: shape, scale, with density ∝ x⁻⁽ᵅ⁺¹⁾ exp(−β/x) |  |
| `"exponential"` | λ: rate, with mean 1/λ | 1 |
| `"chisquared"` | ν: degrees of freedom |  |
| `"student"` | ν: degrees of freedom, with location 0 and scale 1 |  |
| `"fisher"` | ν₁ ν₂: degrees of freedom |  |
| `"cauchy"`, `"laplace"`, `"logistic"` | location, scale | 0 1 |
| `"lognormal"` | μ σ: mean and standard deviation of log(X) | 0 1 |
| `"weibull"` | k λ: shape, scale |  |

Errors: `DOMAIN` for an unknown name, a name that isn't a string, a monadic call for a distribution with no standard parameters, invalid parameters (binomial trials or a Poisson rate past 2⁵³ among them) or non-real inputs; `LENGTH` for the wrong number of parameters; `RANK` for matrix parameters or shapes; `SYNTAX` for a dyadic call to `density`, `cdf` or `quantile`; `LIMIT` for oversized shapes. A `quantile` of a probability outside \[0,1\] gives NaN.
