urn-random-0.1.0.0: A package for updatable discrete distributions

Safe HaskellNone
LanguageHaskell2010

Data.Urn.Index

Contents

Synopsis

Types

data Urn a Source #

Instances

Show a => Show (Urn a) Source #

This Show instance prints out the elements from most-weighted to least-weighted; however, do not rely on the order of equally-weighted elements, as this may depend on details of the implementation.

Methods

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

show :: Urn a -> String #

showList :: [Urn a] -> ShowS #

NFData a => NFData (Urn a) Source # 

Methods

rnf :: Urn a -> () #

data Index Source #

Instances

Eq Index Source # 

Methods

(==) :: Index -> Index -> Bool #

(/=) :: Index -> Index -> Bool #

Ord Index Source # 

Methods

compare :: Index -> Index -> Ordering #

(<) :: Index -> Index -> Bool #

(<=) :: Index -> Index -> Bool #

(>) :: Index -> Index -> Bool #

(>=) :: Index -> Index -> Bool #

max :: Index -> Index -> Index #

min :: Index -> Index -> Index #

NFData Index Source # 

Methods

rnf :: Index -> () #

class Monad m => MonadSample m Source #

Instances

MonadSample IO Source # 

Methods

randomWord :: (Word, Word) -> IO Word Source #

MonadSample Gen Source # 

Methods

randomWord :: (Word, Word) -> Gen Word Source #

MonadSample m => MonadSample (MaybeT m) Source # 

Methods

randomWord :: (Word, Word) -> MaybeT m Word Source #

(Monad m, RandomGen g) => MonadSample (RandT g m) Source # 

Methods

randomWord :: (Word, Word) -> RandT g m Word Source #

MonadSample m => MonadSample (ExceptT e m) Source # 

Methods

randomWord :: (Word, Word) -> ExceptT e m Word Source #

MonadSample m => MonadSample (StateT s m) Source # 

Methods

randomWord :: (Word, Word) -> StateT s m Word Source #

MonadSample m => MonadSample (StateT s m) Source # 

Methods

randomWord :: (Word, Word) -> StateT s m Word Source #

(MonadSample m, Monoid w) => MonadSample (WriterT w m) Source # 

Methods

randomWord :: (Word, Word) -> WriterT w m Word Source #

(MonadSample m, Monoid w) => MonadSample (WriterT w m) Source # 

Methods

randomWord :: (Word, Word) -> WriterT w m Word Source #

MonadSample m => MonadSample (IdentityT * m) Source # 
MonadSample m => MonadSample (ContT * r m) Source # 

Methods

randomWord :: (Word, Word) -> ContT * r m Word Source #

MonadSample m => MonadSample (ReaderT * r m) Source # 

Methods

randomWord :: (Word, Word) -> ReaderT * r m Word Source #

(MonadSample m, Monoid w) => MonadSample (RWST r w s m) Source # 

Methods

randomWord :: (Word, Word) -> RWST r w s m Word Source #

(MonadSample m, Monoid w) => MonadSample (RWST r w s m) Source # 

Methods

randomWord :: (Word, Word) -> RWST r w s m Word Source #

Constructing Urns

singleton :: Weight -> a -> Urn a Source #

fromList :: [(Weight, a)] -> Maybe (Urn a) Source #

Constructing indices

Sampling

sample :: Urn a -> Index -> a Source #

remove :: Urn a -> Index -> (Weight, a, Maybe (Urn a)) Source #

Updating

insert :: Weight -> a -> Urn a -> Urn a Source #

update :: (Weight -> a -> (Weight, a)) -> Urn a -> Index -> (Weight, a, Weight, a, Urn a) Source #

replace :: Weight -> a -> Urn a -> Index -> (Weight, a, Urn a) Source #

Other functions

addToUrn :: Foldable t => Urn a -> t (Weight, a) -> Urn a Source #

Urn properties

size :: Urn a -> Word Source #