chainer.distributions.Categorical¶
-
class
chainer.distributions.Categorical(p=None, **kwargs)[source]¶ Categorical Distribution.
The probability mass function of the distribution is expressed as
\[P(x = i; p) = p_i\]- Parameters
p (
Variableor N-dimensional array) – Parameter of distribution.logit (
Variableor N-dimensional array) – Parameter of distribution representing \(\log\{p\} + C\). Either p or logit (not both) must have a value.
Methods
-
cdf(x)[source]¶ Evaluates the cumulative distribution function at the given points.
- Parameters
x (
Variableor N-dimensional array) – Data points in the domain of the distribution- Returns
Cumulative distribution function value evaluated at x.
- Return type
-
icdf(x)[source]¶ Evaluates the inverse cumulative distribution function at the given points.
- Parameters
x (
Variableor N-dimensional array) – Data points in the domain of the distribution- Returns
Inverse cumulative distribution function value evaluated at x.
- Return type
-
log_cdf(x)[source]¶ Evaluates the log of cumulative distribution function at the given points.
- Parameters
x (
Variableor N-dimensional array) – Data points in the domain of the distribution- Returns
Logarithm of cumulative distribution function value evaluated at x.
- Return type
-
log_prob(x)[source]¶ Evaluates the logarithm of probability at the given points.
- Parameters
x (
Variableor N-dimensional array) – Data points in the domain of the distribution- Returns
Logarithm of probability evaluated at x.
- Return type
-
log_survival_function(x)[source]¶ Evaluates the logarithm of survival function at the given points.
- Parameters
x (
Variableor N-dimensional array) – Data points in the domain of the distribution- Returns
Logarithm of survival function value evaluated at x.
- Return type
-
perplexity(x)[source]¶ Evaluates the perplexity function at the given points.
- Parameters
x (
Variableor N-dimensional array) – Data points in the domain of the distribution- Returns
Perplexity function value evaluated at x.
- Return type
-
prob(x)[source]¶ Evaluates probability at the given points.
- Parameters
x (
Variableor N-dimensional array) – Data points in the domain of the distribution- Returns
Probability evaluated at x.
- Return type
-
sample(sample_shape=())[source]¶ Samples random points from the distribution.
This function calls sample_n and reshapes a result of sample_n to sample_shape + batch_shape + event_shape. On implementing sampling code in an inherited ditribution class, it is not recommended to override this function. Instead of doing this, it is preferable to override sample_n.
-
sample_n(n)[source]¶ Samples n random points from the distribution.
This function returns sampled points whose shape is (n,) + batch_shape + event_shape. When implementing sampling code in a subclass, it is recommended to override this method.
-
survival_function(x)[source]¶ Evaluates the survival function at the given points.
- Parameters
x (
Variableor N-dimensional array) – Data points in the domain of the distribution- Returns
Survival function value evaluated at x.
- Return type
Attributes
-
batch_shape¶ Returns the shape of a batch.
- Returns
The shape of a sample that is not identical and independent.
- Return type
-
covariance¶ Returns the covariance of the distribution.
- Returns
The covariance of the distribution.
- Return type
-
entropy¶
-
event_shape¶ Returns the shape of an event.
- Returns
The shape of a sample that is not identical and independent.
- Return type
-
log_p¶
-
mean¶ Returns the mean of the distribution.
- Returns
The mean of the distribution.
- Return type
-
mode¶ Returns the mode of the distribution.
- Returns
The mode of the distribution.
- Return type
-
p¶
-
params¶ Returns the parameters of the distribution.
- Returns
The parameters of the distribution.
- Return type
-
stddev¶ Returns the standard deviation of the distribution.
- Returns
The standard deviation of the distribution.
- Return type
-
support¶ Returns the support of the distribution.
- Returns
String that means support of this distribution.
- Return type
-
variance¶ Returns the variance of the distribution.
- Returns
The variance of the distribution.
- Return type