logprob

Crates.iologprob
lib.rslogprob
version0.2.0
sourcesrc
created_at2024-01-17 17:07:34.786252
updated_at2024-01-19 15:48:05.727646
descriptionA wrapper around floats to handle log probabilities
homepage
repositoryhttps://github.com/michaelgoodale/logprob/
max_upload_size
id1103265
size32,919
Michael Goodale (MichaelGoodale)

documentation

README

logprob

This crate defines a basic LogProb wrapper for floats. The struct is designed so that only values that are coherent for a log-probability are acceptable. This means that LogProb can store:

  • Any finite negative float value (e.g. -0.23, -32535.05, -66.0).
  • Negative infinity (corresponding to 0.0 probability)
  • 0.0 and -0.0.

The crate is intended for careful implementations of computations involving log-probabilities.

Features:

  • A way to add LogProbs (equivalent take the product of their corresponding raw probabilities)
  • Take the product of a LogProb and an unsigned integer (e.g. equivalent to p^n).
  • Ord and Eq trait on LogProb as there is no NaN.
  • A relatively efficient implementation of LogSumExp for slices and iterators.

For examples, see the documentation.

Commit count: 0

cargo fmt