scipy.stats.dirichlet¶
- scipy.stats.dirichlet = <scipy.stats._multivariate.dirichlet_gen object at 0x2b23194d1f50>[source]¶
A Dirichlet random variable.
The alpha keyword specifies the concentration parameters of the distribution.
New in version 0.15.0.
Parameters: x : array_like
Quantiles, with the last axis of x denoting the components.
alpha : array_like
The concentration parameters. The number of entries determines the dimensionality of the distribution.
random_state : None or int or np.random.RandomState instance, optional
If int or RandomState, use it for drawing the random variates. If None (or np.random), the global np.random state is used. Default is None.
Alternatively, the object may be called (as a function) to fix
concentration parameters, returning a “frozen” Dirichlet
random variable:
rv = dirichlet(alpha)
- Frozen object with the same methods but holding the given concentration parameters fixed.
Notes
Each \(\alpha\) entry must be positive. The distribution has only support on the simplex defined by
\[\sum_{i=1}^{K} x_i \le 1\]The probability density function for dirichlet is
\[f(x) = \frac{1}{\mathrm{B}(\boldsymbol\alpha)} \prod_{i=1}^K x_i^{\alpha_i - 1}\]where
\[\mathrm{B}(\boldsymbol\alpha) = \frac{\prod_{i=1}^K \Gamma(\alpha_i)} {\Gamma\bigl(\sum_{i=1}^K \alpha_i\bigr)}\]and \(\boldsymbol\alpha=(\alpha_1,\ldots,\alpha_K)\), the concentration parameters and \(K\) is the dimension of the space where \(x\) takes values.
Note that the dirichlet interface is somewhat inconsistent. The array returned by the rvs function is transposed with respect to the format expected by the pdf and logpdf.
Methods
pdf(x, alpha) Probability density function. logpdf(x, alpha) Log of the probability density function. rvs(alpha, size=1, random_state=None) Draw random samples from a Dirichlet distribution. mean(alpha) The mean of the Dirichlet distribution var(alpha) The variance of the Dirichlet distribution entropy(alpha) Compute the differential entropy of the Dirichlet distribution.