Skip to content

feat: add categorical distribution#16

Merged
kholdrex merged 1 commit into
masterfrom
feat/categorical-distribution
Jun 6, 2026
Merged

feat: add categorical distribution#16
kholdrex merged 1 commit into
masterfrom
feat/categorical-distribution

Conversation

@kholdrex

@kholdrex kholdrex commented Jun 6, 2026

Copy link
Copy Markdown
Member

Summary

Adds a categorical distribution for finite discrete choices, expanding the existing discrete distribution API beyond Bernoulli, Binomial, and Poisson. The implementation accepts non-negative category weights, normalizes them, and samples category indices with deterministic seeded RNG support.

Changes

  • Add Categorical with parameter validation, normalized probability access, PMF/log-PMF, mean/variance, and sampling through DiscreteDistribution.
  • Cover analytical probabilities, zero-probability categories, invalid weights, seeded sampling, and trailing zero-weight sampling behavior.
  • Update the discrete distribution example and README to show categorical usage.

Test plan

  • Rust format check passed.
  • Strict Clippy passed across all targets and features.
  • Full test suite passed with all features.
  • Rust documentation built with warnings denied.
  • Benchmarks compiled successfully.
  • Independent review found no blocking findings.

@kholdrex kholdrex merged commit 2025774 into master Jun 6, 2026
7 checks passed
@kholdrex kholdrex deleted the feat/categorical-distribution branch June 6, 2026 13:49
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