Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-introduce normalize #243

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Control/Monad/Bayes/Population.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Control.Monad.Bayes.Population
fromWeightedList,
spawn,
multinomial,
normalize,
resampleMultinomial,
systematic,
resampleSystematic,
Expand Down Expand Up @@ -50,6 +51,7 @@ import Control.Monad.Bayes.Weighted
( Weighted,
applyWeight,
extractWeight,
unweighted,
weighted,
withWeight,
)
Expand Down Expand Up @@ -274,3 +276,7 @@ hoist ::
Population m a ->
Population n a
hoist f = fromWeightedList . f . population

-- | Normalizes the weights in the population so that their sum is 1.
normalize :: (Monad m) => Population m a -> Population m a
normalize = hoist unweighted . extractEvidence
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unweighted used to be called prior https://hackage.haskell.org/package/monad-bayes-0.1.1.0/docs/src/Control.Monad.Bayes.Population.html#normalize, so I guess this is the same implementation as before. Shouldn't we restore the comment about bias here?