Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logprob

crates.io docs.rs license

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 to taking the product of their corresponding raw probabilities)
  • Take the product of a LogProb and an unsigned integer (e.g. equivalent to $p^n$).
  • Ord, Eq and Hash trait on LogProb as there is no NaN.
  • A relatively efficient implementation of LogSumExp for slices and iterators.
  • no_std support by disabling the std feature flag (allocations are required for some functions, which can be enabled with the alloc feature flag).

For examples, see the documentation.

About

A wrapper around floats to handle log probabilities

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages