Skip to content

Commit

Permalink
WIP probably fix normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
turion committed Oct 4, 2023
1 parent d6a3020 commit 9aadce1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rhine-bayes/src/Data/MonadicStreamFunction/Bayes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ ppmmhS resPar resState = go
MSF m a ([b], [p])
go parMSFs stateMSFs = MSF $ \a -> do
pars <- forM parMSFs $ flip unMSF a
bAndStateMSFs <- forM pars $ \(p, _) -> runPopulation $ normalize $ resState $ flip unMSF (a, p) =<< fromWeightedList (pure $ (, 1) <$> stateMSFs)
bAndStateMSFs <- forM pars $ \(p, _) -> runPopulation $ flip unMSF (a, p) =<< fromWeightedList (pure $ (, 1) <$> stateMSFs)
let parWeights = sum . fmap snd <$> bAndStateMSFs
-- FIXME it's not so nice that the next step is in m, but the side effects should all be pure
parMSFs' <- runPopulation $ resPar $ fromWeightedList $ pure $ zip (snd <$> pars) parWeights
let bAndStateMSFsT = transpose bAndStateMSFs
bAndStateMSFsT <- transpose <$> mapM (runPopulation . normalize . resState . fromWeightedList . pure) bAndStateMSFs
bAndStateMSFs <- forM bAndStateMSFsT $ \forallParameters -> do
choice <- logCategorical $ fromList $ snd <$> forallParameters
pure $ fst $ forallParameters !! choice
Expand Down

0 comments on commit 9aadce1

Please sign in to comment.