Skip to content

Container type for convenient calculations with logspace probabilities

License

Notifications You must be signed in to change notification settings

dharasim/LogProbs.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogProbs

Build Status Coverage Status codecov.io

This package provides the Type LogProb for calculations with logspace probabilities.

Usage

julia> using LogProbs

julia> p = LogProb(0.2)
LogProb(0.2)

julia> q = LogProb(0.5)
LogProb(0.5)

julia> p + q
LogProb(0.7)

julia> float(p + q)
0.7

julia> log(p + q)
-0.35667494393873234

julia> float(p * q)
0.10000000000000002

julia> q - p
LogProb(0.30000000000000004)

julia> q - p == LogProb(0.3)
false

julia> q - p  LogProb(0.3)
true

julia> q / p
LogProb(2.5)

julia> p / q
LogProb(0.4)

julia> rand(LogProb)
LogProb(0.8973798055014042)

julia> p < q, q < p
(true, false)

julia> information(p) # Shannon information content in bits
2.321928094887362

About

Container type for convenient calculations with logspace probabilities

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages