0 | module Control.Monad.Bayes.Inference.SMC2
2 | import Control.Monad.Bayes.Interface
3 | import Control.Monad.Bayes.Inference.RMSMC
4 | import Control.Monad.Bayes.Inference.SMC
5 | import Control.Monad.Bayes.Traced.Static
6 | import Control.Monad.Bayes.Sequential
7 | import Control.Monad.Trans
12 | record SMC2 (m : Type -> Type) (a : Type) where
14 | setup : Sequential (Traced (Population m)) a
17 | Monad m => Functor (SMC2 m) where
18 | map f (MkSMC2 mx) = MkSMC2 (map f mx)
21 | Monad m => Applicative (SMC2 m) where
22 | pure = MkSMC2 . pure
23 | (MkSMC2 mf) <*> (MkSMC2 ma) = MkSMC2 (mf <*> ma)
26 | Monad m => Monad (SMC2 m) where
27 | (MkSMC2 mx) >>= k = MkSMC2 ((assert_total (>>=)) mx (setup . k))
30 | MonadTrans SMC2 where
31 | lift = MkSMC2 . lift . lift . lift
34 | MonadSample m => MonadSample (SMC2 m) where
35 | random = lift random
38 | Monad m => MonadCond (SMC2 m) where
39 | score w = MkSMC2 $
score w
42 | MonadSample m => MonadInfer (SMC2 m) where
49 | (n_timesteps : Nat) ->
51 | (n_inner_particles : Nat) ->
53 | (n_outer_particles : Nat) ->
55 | (n_mhsteps : Nat) ->
57 | Sequential (Traced (Population m)) b ->
59 | (b -> Sequential (Population (SMC2 m)) a) ->
60 | Population m (List (Log Double, a))
61 | smc2 n_timesteps n_inner_particles n_outer_particles n_mhsteps param model =
62 | rmsmc n_timesteps n_outer_particles n_mhsteps
63 | (param >>= setup . runPopulation . smcSystematicPush n_timesteps n_inner_particles . model)