tfd_finite_discrete: The finite discrete distribution.

View source: R/distributions.R

tfd_finite_discreteR Documentation

The finite discrete distribution.

Description

The FiniteDiscrete distribution is parameterized by either probabilities or log-probabilities of a set of K possible outcomes, which is defined by a strictly ascending list of K values.

Usage

tfd_finite_discrete(
  outcomes,
  logits = NULL,
  probs = NULL,
  rtol = NULL,
  atol = NULL,
  validate_args = FALSE,
  allow_nan_stats = TRUE,
  name = "FiniteDiscrete"
)

Arguments

outcomes

A 1-D floating or integer Tensor, representing a list of possible outcomes in strictly ascending order.

logits

A floating N-D Tensor, N >= 1, representing the log probabilities of a set of FiniteDiscrete distributions. The first N - 1 dimensions index into a batch of independent distributions and the last dimension represents a vector of logits for each discrete value. Only one of logits or probs should be passed in.

probs

A floating N-D Tensor, N >= 1, representing the probabilities of a set of FiniteDiscrete distributions. The first N - 1 dimensions index into a batch of independent distributions and the last dimension represents a vector of probabilities for each discrete value. Only one of logits or probs should be passed in.

rtol

Tensor with same dtype as outcomes. The relative tolerance for floating number comparison. Only effective when outcomes is a floating Tensor. Default is 10 * eps.

atol

Tensor with same dtype as outcomes. The absolute tolerance for floating number comparison. Only effective when outcomes is a floating Tensor. Default is 10 * eps.

validate_args

Logical, default FALSE. When TRUE distribution parameters are checked for validity despite possibly degrading runtime performance. When FALSE invalid inputs may silently render incorrect outputs. Default value: FALSE.

allow_nan_stats

Logical, default TRUE. When TRUE, statistics (e.g., mean, mode, variance) use the value NaN to indicate the result is undefined. When FALSE, an exception is raised if one or more of the statistic's batch members are undefined.

name

string prefixed to Ops created by this class.

Details

Note: log_prob, prob, cdf, mode, and entropy are differentiable with respect to logits or probs but not with respect to outcomes.

Mathematical Details

The probability mass function (pmf) is,

pmf(x; pi, qi) = prod_j pi_j**[x == qi_j]

Value

a distribution instance.

See Also

For usage examples see e.g. tfd_sample(), tfd_log_prob(), tfd_mean().


tfprobability documentation built on Sept. 1, 2022, 5:07 p.m.