approximate-0.2.2.1: Approximate discrete values and numbers

Copyright (c) Edward Kmett 2013 BSD3 Edward Kmett experimental non-portable None Haskell98

Data.Approximate.Mass

Description

Synopsis

Documentation

data Mass a Source

A quantity with a lower-bound on its probability mass. This represents a 'probable value' as a `Monad` that you can use to calculate progressively less likely consequences.

NB: These probabilities are all stored in the log domain. This enables us to retain accuracy despite very long multiplication chains. We never add these probabilities so the additional overhead of working in the log domain is never incurred, except on transitioning in and out.

This is most useful for discrete types, such as small `Integral` instances or a `Bounded` `Enum` like `Bool`.

Also note that `(&?)` and `(|?)` are able to use knowledge about the function to get better precision on their results than naively using `liftA2 (&&)`

Constructors

 Mass !(Log Double) a

Instances

 Monad Mass Functor Mass Applicative Mass Foldable Mass Traversable Mass Serial1 Mass Comonad Mass ComonadApply Mass Hashable1 Mass Pointed Mass Copointed Mass Apply Mass Bind Mass Extend Mass Unbox a => Vector Vector (Mass a) Unbox a => MVector MVector (Mass a) Eq a => Eq (Mass a) Data a => Data (Mass a) Ord a => Ord (Mass a) Read a => Read (Mass a) Show a => Show (Mass a) Generic (Mass a) Monoid a => Monoid (Mass a) Binary a => Binary (Mass a) Serial a => Serial (Mass a) Serialize a => Serialize (Mass a) NFData a => NFData (Mass a) Hashable a => Hashable (Mass a) Semigroup a => Semigroup (Mass a) Serialize a => SafeCopy (Mass a) Typeable (* -> *) Mass data MVector s (Mass a) = MV_Mass (MVector s (Log Double, a)) type Rep (Mass a) data Vector (Mass a) = V_Mass (Vector (Log Double, a))

(|?) :: Mass Bool -> Mass Bool -> Mass Bool infixr 2 Source

Calculate the logical `or` of two booleans with confidence lower bounds.

(&?) :: Mass Bool -> Mass Bool -> Mass Bool infixr 3 Source

Calculate the logical `and` of two booleans with confidence lower bounds.

(^?) :: Mass Bool -> Mass Bool -> Mass Bool infixl 6 Source

Calculate the exclusive `or` of two booleans with confidence lower bounds.