Loading [MathJax]/jax/input/TeX/config.js
scipy 1.10.1 Pypi GitHub Homepage
Other Docs

MethodsNotesParameters

The alpha keyword specifies the concentration parameters of the distribution.

Methods

Notes

Each \alpha entry must be positive. The distribution has only support on the simplex defined by

\sum_{i=1}^{K} x_i = 1

where 0 < x_i < 1.

If the quantiles don't lie within the simplex, a ValueError is raised.

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.

Parameters

%(_dirichlet_doc_default_callparams)s :
%(_doc_random_state)s :

A Dirichlet random variable.

Examples

import numpy as np
from scipy.stats import dirichlet
Generate a dirichlet random variable
quantiles = np.array([0.2, 0.2, 0.6])  # specify quantiles
alpha = np.array([0.4, 5, 15])  # specify concentration parameters
dirichlet.pdf(quantiles, alpha)
The same PDF but following a log scale
dirichlet.logpdf(quantiles, alpha)
Once we specify the dirichlet distribution we can then calculate quantities of interest
dirichlet.mean(alpha)  # get the mean of the distribution
dirichlet.var(alpha) # get variance
dirichlet.entropy(alpha)  # calculate the differential entropy
We can also return random samples from the distribution
dirichlet.rvs(alpha, size=1, random_state=1)
dirichlet.rvs(alpha, size=2, random_state=2)
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.
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/stats/_multivariate.py#1417
type: <class 'type'>
Commit: