{ } Raw JSON

bundles / scipy latest / scipy / stats / _multivariate / dirichlet_gen

class

scipy.stats._multivariate:dirichlet_gen

source: /scipy/stats/_multivariate.py :2260

Signature

class   dirichlet_gen ( seed = None )

Members

Summary

A Dirichlet random variable.

Extended Summary

The alpha keyword specifies the concentration parameters of the distribution.

Parameters

%(_dirichlet_doc_default_callparams)s
%(_doc_random_state)s

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

cov(alpha)

The covariance of the Dirichlet distribution

entropy(alpha)

Compute the differential entropy of the Dirichlet distribution.

Notes

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

where .

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

The probability density function for dirichlet is

where

and , the concentration parameters and is the dimension of the space where 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.

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)

Aliases

  • scipy.stats._multivariate.dirichlet_gen