torch_concepts.distributions.Delta

class Delta(value: List[float] | Tensor, validate_args=None)[source]

Delta (Dirac delta) distribution - a deterministic distribution.

This distribution always returns the same fixed value when sampled, making it useful for representing deterministic variables in Probabilistic Models.

The Delta distribution has zero variance and assigns all probability mass to a single point.

arg_constraints

Empty dict - no constraints on parameters.

Type:

Dict

support

Support of the distribution (None for Delta).

Type:

Optional[torch.Tensor]

has_rsample

Whether reparameterized sampling is supported (False).

Type:

bool

Parameters:
  • value – The deterministic value (list or tensor).

  • validate_args – Whether to validate arguments (default: None).

Properties:

mean: Returns the deterministic value.

Examples

>>> import torch
>>> from torch_concepts.distributions import Delta
>>> dist = Delta(torch.tensor([1.0, 2.0, 3.0]))
>>> sample = dist.sample()
>>> print(sample)  # tensor([1., 2., 3.])
>>> print(dist.mean)  # tensor([1., 2., 3.])
__init__(value: List[float] | Tensor, validate_args=None)[source]

Initialize a Delta distribution.

Parameters:
  • value – The fixed value this distribution returns (list or tensor).

  • validate_args – Whether to validate arguments (default: None).

Methods

__init__(value[, validate_args])

Initialize a Delta distribution.

cdf(value)

Returns the cumulative density/mass function evaluated at value.

entropy()

Returns entropy of distribution, batched over batch_shape.

enumerate_support([expand])

Returns tensor containing all values supported by a discrete distribution.

expand(batch_shape[, _instance])

Returns a new distribution instance (or populates an existing instance provided by a derived class) with batch dimensions expanded to batch_shape.

icdf(value)

Returns the inverse cumulative density/mass function evaluated at value.

log_prob(value)

Calculate the log probability of a value.

perplexity()

Returns perplexity of distribution, batched over batch_shape.

rsample([sample_shape])

Generate a reparameterized sample from the distribution.

sample([sample_shape])

Generate a sample from the distribution.

sample_n(n)

Generates n samples or n batches of samples if the distribution parameters are batched.

set_default_validate_args(value)

Sets whether validation is enabled or disabled.

Attributes

arg_constraints

batch_shape

Returns the shape over which parameters are batched.

event_shape

Returns the shape of a single sample (without batching).

has_enumerate_support

has_rsample

mean

Return the mean of the distribution.

mode

Returns the mode of the distribution.

stddev

Returns the standard deviation of the distribution.

support

variance

Returns the variance of the distribution.