Skip to content

Add dirac distribution - #28

Merged
mctigger merged 3 commits into
mainfrom
add-dirac-distribution
Oct 12, 2025
Merged

Add dirac distribution#28
mctigger merged 3 commits into
mainfrom
add-dirac-distribution

Conversation

@mctigger

@mctigger mctigger commented Oct 3, 2025

Copy link
Copy Markdown
Owner

No description provided.

Tim Joseph added 3 commits September 29, 2025 09:30
The DiracDistribution represents a point mass distribution, concentrating
all probability at a single value. This is useful for modeling deterministic
variables or as a degenerate case in probabilistic models.
Introduces `TensorDirac`, a tensor-aware implementation of the Dirac
delta (point mass) distribution. This distribution assigns probability
one to a single support element.

Key features include:
- `sample` and `rsample` always return the point `value`.
- `log_prob` is 0 for the exact `value` and -inf otherwise.
- Correct implementation of statistical properties like `mean`,
  `variance`, `entropy`, `cdf`, and `icdf`.
- Comprehensive test suite covering API matching, core operations,
  and `torch.compile` compatibility.
Introduces `atol` (absolute tolerance) and `rtol` (relative tolerance)
parameters to `DiracDistribution` and `TensorDirac`. These parameters
enable approximate equality checks for `log_prob` and `cdf` computations,
addressing limitations of exact floating-point comparisons.

The `icdf` method was also updated to correctly broadcast the point mass
value. Default `atol` and `rtol` values are 0, maintaining existing
exact equality behavior unless specified.
@mctigger
mctigger merged commit 58df319 into main Oct 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant