Importance.hs (342B)
1 2 module Deanie.Inference.Importance ( 3 importance 4 ) where 5 6 import qualified Control.Foldl as L 7 8 importance 9 :: (Foldable f, Monad m, Floating w) 10 => f a -> m b -> (b -> a -> w) 11 -> m (w, b) 12 importance obs prior model = do 13 parameter <- prior 14 let cost = L.fold (L.premap (model parameter) L.sum) obs 15 return (exp cost, parameter) 16