The alpha
keyword specifies the concentration parameters of the distribution.
Each \alpha entry must be positive. The distribution has only support on the simplex defined by
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
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.
A Dirichlet random variable.
import numpy as np
from scipy.stats import dirichlet
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)
dirichlet.logpdf(quantiles, alpha)
dirichlet.mean(alpha) # get the mean of the distribution
dirichlet.var(alpha) # get variance
dirichlet.entropy(alpha) # calculate the differential entropy
dirichlet.rvs(alpha, size=1, random_state=1)
dirichlet.rvs(alpha, size=2, random_state=2)
rv = dirichlet(alpha)
# Frozen object with the same methods but holding the given
# concentration parameters fixed.
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