approximate-0.3.1: Approximate discrete values and numbers

Copyright(c) Edward Kmett 2013
LicenseBSD3
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

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 Source # 

Methods

(>>=) :: Mass a -> (a -> Mass b) -> Mass b #

(>>) :: Mass a -> Mass b -> Mass b #

return :: a -> Mass a #

fail :: String -> Mass a #

Functor Mass Source # 

Methods

fmap :: (a -> b) -> Mass a -> Mass b #

(<$) :: a -> Mass b -> Mass a #

Applicative Mass Source # 

Methods

pure :: a -> Mass a #

(<*>) :: Mass (a -> b) -> Mass a -> Mass b #

(*>) :: Mass a -> Mass b -> Mass b #

(<*) :: Mass a -> Mass b -> Mass a #

Foldable Mass Source # 

Methods

fold :: Monoid m => Mass m -> m #

foldMap :: Monoid m => (a -> m) -> Mass a -> m #

foldr :: (a -> b -> b) -> b -> Mass a -> b #

foldr' :: (a -> b -> b) -> b -> Mass a -> b #

foldl :: (b -> a -> b) -> b -> Mass a -> b #

foldl' :: (b -> a -> b) -> b -> Mass a -> b #

foldr1 :: (a -> a -> a) -> Mass a -> a #

foldl1 :: (a -> a -> a) -> Mass a -> a #

toList :: Mass a -> [a] #

null :: Mass a -> Bool #

length :: Mass a -> Int #

elem :: Eq a => a -> Mass a -> Bool #

maximum :: Ord a => Mass a -> a #

minimum :: Ord a => Mass a -> a #

sum :: Num a => Mass a -> a #

product :: Num a => Mass a -> a #

Traversable Mass Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Mass a -> f (Mass b) #

sequenceA :: Applicative f => Mass (f a) -> f (Mass a) #

mapM :: Monad m => (a -> m b) -> Mass a -> m (Mass b) #

sequence :: Monad m => Mass (m a) -> m (Mass a) #

Serial1 Mass Source # 

Methods

serializeWith :: MonadPut m => (a -> m ()) -> Mass a -> m () #

deserializeWith :: MonadGet m => m a -> m (Mass a) #

Comonad Mass Source # 

Methods

extract :: Mass a -> a #

duplicate :: Mass a -> Mass (Mass a) #

extend :: (Mass a -> b) -> Mass a -> Mass b #

ComonadApply Mass Source # 

Methods

(<@>) :: Mass (a -> b) -> Mass a -> Mass b #

(@>) :: Mass a -> Mass b -> Mass b #

(<@) :: Mass a -> Mass b -> Mass a #

Hashable1 Mass Source # 

Methods

liftHashWithSalt :: (Int -> a -> Int) -> Int -> Mass a -> Int #

Copointed Mass Source # 

Methods

copoint :: Mass a -> a #

Pointed Mass Source # 

Methods

point :: a -> Mass a #

Apply Mass Source # 

Methods

(<.>) :: Mass (a -> b) -> Mass a -> Mass b #

(.>) :: Mass a -> Mass b -> Mass b #

(<.) :: Mass a -> Mass b -> Mass a #

Bind Mass Source # 

Methods

(>>-) :: Mass a -> (a -> Mass b) -> Mass b #

join :: Mass (Mass a) -> Mass a #

Extend Mass Source # 

Methods

duplicated :: Mass a -> Mass (Mass a) #

extended :: (Mass a -> b) -> Mass a -> Mass b #

Unbox a => Vector Vector (Mass a) Source # 

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Mass a) -> m (Vector (Mass a)) #

basicUnsafeThaw :: PrimMonad m => Vector (Mass a) -> m (Mutable Vector (PrimState m) (Mass a)) #

basicLength :: Vector (Mass a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Mass a) -> Vector (Mass a) #

basicUnsafeIndexM :: Monad m => Vector (Mass a) -> Int -> m (Mass a) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Mass a) -> Vector (Mass a) -> m () #

elemseq :: Vector (Mass a) -> Mass a -> b -> b #

Unbox a => MVector MVector (Mass a) Source # 

Methods

basicLength :: MVector s (Mass a) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (Mass a) -> MVector s (Mass a) #

basicOverlaps :: MVector s (Mass a) -> MVector s (Mass a) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Mass a)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (Mass a) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> Mass a -> m (MVector (PrimState m) (Mass a)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Mass a) -> Int -> m (Mass a) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Mass a) -> Int -> Mass a -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (Mass a) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (Mass a) -> Mass a -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Mass a) -> MVector (PrimState m) (Mass a) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Mass a) -> MVector (PrimState m) (Mass a) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Mass a) -> Int -> m (MVector (PrimState m) (Mass a)) #

Eq a => Eq (Mass a) Source # 

Methods

(==) :: Mass a -> Mass a -> Bool #

(/=) :: Mass a -> Mass a -> Bool #

Data a => Data (Mass a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Mass a -> c (Mass a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Mass a) #

toConstr :: Mass a -> Constr #

dataTypeOf :: Mass a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Mass a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Mass a)) #

gmapT :: (forall b. Data b => b -> b) -> Mass a -> Mass a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Mass a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Mass a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Mass a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Mass a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Mass a -> m (Mass a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Mass a -> m (Mass a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Mass a -> m (Mass a) #

Ord a => Ord (Mass a) Source # 

Methods

compare :: Mass a -> Mass a -> Ordering #

(<) :: Mass a -> Mass a -> Bool #

(<=) :: Mass a -> Mass a -> Bool #

(>) :: Mass a -> Mass a -> Bool #

(>=) :: Mass a -> Mass a -> Bool #

max :: Mass a -> Mass a -> Mass a #

min :: Mass a -> Mass a -> Mass a #

Read a => Read (Mass a) Source # 
Show a => Show (Mass a) Source # 

Methods

showsPrec :: Int -> Mass a -> ShowS #

show :: Mass a -> String #

showList :: [Mass a] -> ShowS #

Generic (Mass a) Source # 

Associated Types

type Rep (Mass a) :: * -> * #

Methods

from :: Mass a -> Rep (Mass a) x #

to :: Rep (Mass a) x -> Mass a #

Semigroup a => Semigroup (Mass a) Source # 

Methods

(<>) :: Mass a -> Mass a -> Mass a #

sconcat :: NonEmpty (Mass a) -> Mass a #

stimes :: Integral b => b -> Mass a -> Mass a #

Monoid a => Monoid (Mass a) Source # 

Methods

mempty :: Mass a #

mappend :: Mass a -> Mass a -> Mass a #

mconcat :: [Mass a] -> Mass a #

Binary a => Binary (Mass a) Source # 

Methods

put :: Mass a -> Put #

get :: Get (Mass a) #

putList :: [Mass a] -> Put #

Serial a => Serial (Mass a) Source # 

Methods

serialize :: MonadPut m => Mass a -> m () #

deserialize :: MonadGet m => m (Mass a) #

Serialize a => Serialize (Mass a) Source # 

Methods

put :: Putter (Mass a) #

get :: Get (Mass a) #

NFData a => NFData (Mass a) Source # 

Methods

rnf :: Mass a -> () #

Hashable a => Hashable (Mass a) Source # 

Methods

hashWithSalt :: Int -> Mass a -> Int #

hash :: Mass a -> Int #

Serialize a => SafeCopy (Mass a) Source # 
data MVector s (Mass a) Source # 
data MVector s (Mass a) = MV_Mass (MVector s (Log Double, a))
type Rep (Mass a) Source # 
type Rep (Mass a) = D1 (MetaData "Mass" "Data.Approximate.Mass" "approximate-0.3.1-FS3hJ0LU8K8BWgM9AgtLk8" False) (C1 (MetaCons "Mass" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) SourceUnpack SourceStrict DecidedUnpack) (Rec0 (Log Double))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))))
data Vector (Mass a) Source # 
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.