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

Bump monad bayes to 1.2.0 #271

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rhine-bayes/rhine-bayes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ library
, rhine == 1.1
, dunai ^>= 0.11
, log-domain >= 0.12
, monad-bayes ^>= 1.1
, monad-bayes ^>= 1.2
hs-source-dirs: src
default-language: Haskell2010
default-extensions:
Expand Down
18 changes: 9 additions & 9 deletions rhine-bayes/src/Data/MonadicStreamFunction/Bayes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ runPopulationS ::
-- | Number of particles
Int ->
-- | Resampler
(forall x. Population m x -> Population m x) ->
MSF (Population m) a b ->
-- FIXME Why not MSF m a (Population b)
(forall x. PopulationT m x -> PopulationT m x) ->
MSF (PopulationT m) a b ->
-- FIXME Why not MSF m a (PopulationT b)
MSF m a [(b, Log Double)]
runPopulationS nParticles resampler = runPopulationsS resampler . (spawn nParticles $>)

-- | Run the Sequential Monte Carlo algorithm continuously on a 'Population' of 'MSF's
-- | Run the Sequential Monte Carlo algorithm continuously on a 'PopulationT' of 'MSF's
runPopulationsS ::
(Monad m) =>
-- | Resampler
(forall x. Population m x -> Population m x) ->
Population m (MSF (Population m) a b) ->
(forall x. PopulationT m x -> PopulationT m x) ->
PopulationT m (MSF (PopulationT m) a b) ->
MSF m a [(b, Log Double)]
runPopulationsS resampler = go
where
go msfs = MSF $ \a -> do
-- TODO This is quite different than the dunai version now. Maybe it's right nevertheless.
-- FIXME This normalizes, which introduces bias, whatever that means
bAndMSFs <- runPopulation $ normalize $ resampler $ flip unMSF a =<< msfs
bAndMSFs <- runPopulationT $ normalize $ resampler $ flip unMSF a =<< msfs
return $
second (go . fromWeightedList . return) $
unzip $
(swap . fmap fst &&& swap . fmap snd) . swap <$> bAndMSFs

-- FIXME see PR re-adding this to monad-bayes
normalize :: (Monad m) => Population m a -> Population m a
normalize = fromWeightedList . fmap (\particles -> second (/ (sum $ snd <$> particles)) <$> particles) . runPopulation
normalize :: (Monad m) => PopulationT m a -> PopulationT m a
normalize = fromWeightedList . fmap (\particles -> second (/ (sum $ snd <$> particles)) <$> particles) . runPopulationT
6 changes: 3 additions & 3 deletions rhine-bayes/src/FRP/Rhine/Bayes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ runPopulationCl ::
(Monad m) =>
-- | Number of particles
Int ->
-- | Resampler (see 'Control.Monad.Bayes.Population' for some standard choices)
(forall x. Population m x -> Population m x) ->
-- | Resampler (see 'Control.Monad.Bayes.PopulationT' for some standard choices)
(forall x. PopulationT m x -> PopulationT m x) ->
-- | A signal function modelling the stochastic process on which to perform inference.
-- @a@ represents observations upon which the model should condition, using e.g. 'score'.
-- It can also additionally contain hyperparameters.
-- @b@ is the type of estimated current state.
ClSF (Population m) cl a b ->
ClSF (PopulationT m) cl a b ->
ClSF m cl a [(b, Log Double)]
runPopulationCl nParticles resampler = DunaiReader.readerS . DunaiBayes.runPopulationS nParticles resampler . DunaiReader.runReaderS

Expand Down
2 changes: 1 addition & 1 deletion stack.9.0.2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extra-deps:
- simple-affine-space-0.2.1@sha256:bc9b1f5ae236b2898cd6f20da2d4589fd662fac2e2057f29b01330f65c030434,2046
- monad-schedule-0.1.2.1@sha256:95d6b9c6fd36f585e4a52938ebd1762c2e2caa8bb3c11ce86985dd11a2caae1a,1776
- time-domain-0.1.0.2@sha256:33f0a6efe6eb03e729f3dc828cd673b0bb511a0e50ac0b621c5acebd82f6d329,1007
- monad-bayes-1.1.1
- monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
- criterion-1.6.3.0
- criterion-measurement-0.2.1.0@sha256:646d5b5c55499580747746396b731ef9d6e2cd59fa7b488354788e68eae8e9bc,2098
- hspec-2.11.7@sha256:2869580a2a29e7beb6268ea3dc561583f4ae229ed1f47fb1c92e8c09ce35acec,1763
Expand Down
78 changes: 74 additions & 4 deletions stack.9.0.2.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,82 @@ packages:
original:
hackage: time-domain-0.1.0.2@sha256:33f0a6efe6eb03e729f3dc828cd673b0bb511a0e50ac0b621c5acebd82f6d329,1007
- completed:
hackage: monad-bayes-1.1.1@sha256:d76401f5b7bdcfe0b454f63f932c97049d633ef2623f19981bba02c63af3a16c,6292
hackage: monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
pantry-tree:
sha256: bf2bdaaf51aaa9b24b3ec3757d83db0e9f5507435984a452788e71cc2bd3b9b7
size: 3567
sha256: ce4a9db9888b589ae56493862ae62f2efb5af8d17d3d55bac0b3f59177881b2b
size: 3823
original:
hackage: monad-bayes-1.1.1
hackage: monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
- completed:
hackage: criterion-1.6.3.0@sha256:cf27e6c83f91674fb67ef253cae644ad0ce079b7e2cfa6402e13e930f78499ec,5373
pantry-tree:
sha256: 2102113a4ac228305ea9396967878c6921377bafc92425c1b8cf82f8afbef40e
size: 2323
original:
hackage: criterion-1.6.3.0
- completed:
hackage: criterion-measurement-0.2.1.0@sha256:646d5b5c55499580747746396b731ef9d6e2cd59fa7b488354788e68eae8e9bc,2098
pantry-tree:
sha256: 2557db6ed7b4e5718d9ca6271caf4bcfc97b966ed32b051f346c8d17e1c31809
size: 726
original:
hackage: criterion-measurement-0.2.1.0@sha256:646d5b5c55499580747746396b731ef9d6e2cd59fa7b488354788e68eae8e9bc,2098
- completed:
hackage: hspec-2.11.7@sha256:2869580a2a29e7beb6268ea3dc561583f4ae229ed1f47fb1c92e8c09ce35acec,1763
pantry-tree:
sha256: f241a7710ebee50583f9aebff61aaf4d36619ba7d6538b39b80ee4695c70552e
size: 584
original:
hackage: hspec-2.11.7@sha256:2869580a2a29e7beb6268ea3dc561583f4ae229ed1f47fb1c92e8c09ce35acec,1763
- completed:
hackage: lens-5.2.3@sha256:637287c76adff383063b3206a4213640de1a74839ec16008cc71b5b407f7d05e,15237
pantry-tree:
sha256: 2a69ee338ef79da9aaa0d406f8307b11e3b8f969aa8fc28e46ca250c1f6ef40d
size: 8351
original:
hackage: lens-5.2.3@sha256:637287c76adff383063b3206a4213640de1a74839ec16008cc71b5b407f7d05e,15237
- completed:
hackage: linear-1.22@sha256:6402f0140156d2792ca0cbef3f5af2ec3675660e381574ac968cd5884724b8ba,4132
pantry-tree:
sha256: 8ccd6646c1a5f2f7998a19a04f00200e44ee08186e980153ec371d6d114eb0e6
size: 2042
original:
hackage: linear-1.22@sha256:6402f0140156d2792ca0cbef3f5af2ec3675660e381574ac968cd5884724b8ba,4132
- completed:
hackage: optparse-applicative-0.18.1.0@sha256:b4cf8d9018e5e67cb1f14edb5130b6d05ad8bc1b5f6bd4efaa6ec0b7f28f559d,5132
pantry-tree:
sha256: 32f52adc150eb146bf4d167ff0cb21fc1e3cd7ecc1b9e5e83b986a1cd1bc58cd
size: 3124
original:
hackage: optparse-applicative-0.18.1.0@sha256:b4cf8d9018e5e67cb1f14edb5130b6d05ad8bc1b5f6bd4efaa6ec0b7f28f559d,5132
- completed:
hackage: pretty-simple-4.1.2.0@sha256:1c0a96e4205010d704c52883c53c98258c588ce7196763b408949d9db712ba14,4113
pantry-tree:
sha256: af1fc182e52bace1cb472830a7af4354bf5475056855f4df8137411de6306965
size: 1229
original:
hackage: pretty-simple-4.1.2.0@sha256:1c0a96e4205010d704c52883c53c98258c588ce7196763b408949d9db712ba14,4113
- completed:
hackage: hspec-core-2.11.7@sha256:90d8873356d7e15f843bc523360e206e8e356ff6b82a1fa4b3889dc31d073ea1,6814
pantry-tree:
sha256: 8db12c1f6965d9f0898f04d7b5f1d77682c8ab2d5c394c4a431229df7c4acb14
size: 6231
original:
hackage: hspec-core-2.11.7@sha256:90d8873356d7e15f843bc523360e206e8e356ff6b82a1fa4b3889dc31d073ea1,6814
- completed:
hackage: hspec-discover-2.11.7@sha256:6307eb16d308258a99a242025df50217d835ba0a3f205b1202a100a175877b38,2169
pantry-tree:
sha256: 141b4987d519ad1ca1114737f510f20adc2456bf44c040f41a63792f47d009eb
size: 829
original:
hackage: hspec-discover-2.11.7@sha256:6307eb16d308258a99a242025df50217d835ba0a3f205b1202a100a175877b38,2169
- completed:
hackage: hspec-expectations-0.8.4@sha256:4237f094a7931202ff57ac6475542b0b314b50a7024550e2b6eb87cfb0d4ff93,1702
pantry-tree:
sha256: 87681840d430b84686f83f1ab8b5873b09c349775698665233443914acf9ba2b
size: 741
original:
hackage: hspec-expectations-0.8.4@sha256:4237f094a7931202ff57ac6475542b0b314b50a7024550e2b6eb87cfb0d4ff93,1702
snapshots:
- completed:
sha256: f1c4aca9b9b81afbb9db55571acb0690cdc01ac97a178234de281f9dc075e95e
Expand Down
2 changes: 1 addition & 1 deletion stack.9.2.8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extra-deps:
- dunai-0.11.1@sha256:b527b801c8b3901a4ebec733ac0bb6ff9cdd2b6b04ec385e18922f49c39e4b51,6372
- simple-affine-space-0.2.1@sha256:bc9b1f5ae236b2898cd6f20da2d4589fd662fac2e2057f29b01330f65c030434,2046
- terminal-0.2.0.0@sha256:de6770ecaae3197c66ac1f0db5a80cf5a5b1d3b64a66a05b50f442de5ad39570,2977
- monad-bayes-1.1.1
- monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
- hspec-2.11.7@sha256:2869580a2a29e7beb6268ea3dc561583f4ae229ed1f47fb1c92e8c09ce35acec,1763
- lens-5.2.3@sha256:637287c76adff383063b3206a4213640de1a74839ec16008cc71b5b407f7d05e,15237
- linear-1.22@sha256:6402f0140156d2792ca0cbef3f5af2ec3675660e381574ac968cd5884724b8ba,4132
Expand Down
57 changes: 53 additions & 4 deletions stack.9.2.8.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,61 @@ packages:
original:
hackage: terminal-0.2.0.0@sha256:de6770ecaae3197c66ac1f0db5a80cf5a5b1d3b64a66a05b50f442de5ad39570,2977
- completed:
hackage: monad-bayes-1.1.1@sha256:d76401f5b7bdcfe0b454f63f932c97049d633ef2623f19981bba02c63af3a16c,6292
hackage: monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
pantry-tree:
sha256: bf2bdaaf51aaa9b24b3ec3757d83db0e9f5507435984a452788e71cc2bd3b9b7
size: 3567
sha256: ce4a9db9888b589ae56493862ae62f2efb5af8d17d3d55bac0b3f59177881b2b
size: 3823
original:
hackage: monad-bayes-1.1.1
hackage: monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
- completed:
hackage: hspec-2.11.7@sha256:2869580a2a29e7beb6268ea3dc561583f4ae229ed1f47fb1c92e8c09ce35acec,1763
pantry-tree:
sha256: f241a7710ebee50583f9aebff61aaf4d36619ba7d6538b39b80ee4695c70552e
size: 584
original:
hackage: hspec-2.11.7@sha256:2869580a2a29e7beb6268ea3dc561583f4ae229ed1f47fb1c92e8c09ce35acec,1763
- completed:
hackage: lens-5.2.3@sha256:637287c76adff383063b3206a4213640de1a74839ec16008cc71b5b407f7d05e,15237
pantry-tree:
sha256: 2a69ee338ef79da9aaa0d406f8307b11e3b8f969aa8fc28e46ca250c1f6ef40d
size: 8351
original:
hackage: lens-5.2.3@sha256:637287c76adff383063b3206a4213640de1a74839ec16008cc71b5b407f7d05e,15237
- completed:
hackage: linear-1.22@sha256:6402f0140156d2792ca0cbef3f5af2ec3675660e381574ac968cd5884724b8ba,4132
pantry-tree:
sha256: 8ccd6646c1a5f2f7998a19a04f00200e44ee08186e980153ec371d6d114eb0e6
size: 2042
original:
hackage: linear-1.22@sha256:6402f0140156d2792ca0cbef3f5af2ec3675660e381574ac968cd5884724b8ba,4132
- completed:
hackage: vty-5.38@sha256:c3b46c8072f92b61dad09dac45ede37f1a093836e14ac84ece6515a4d3222864,5628
pantry-tree:
sha256: b413c72281bb0f48eb0e4b45e272e3a18036ea91b4850315e8c2487ef719f9f3
size: 3499
original:
hackage: vty-5.38@sha256:c3b46c8072f92b61dad09dac45ede37f1a093836e14ac84ece6515a4d3222864,5628
- completed:
hackage: hspec-core-2.11.7@sha256:90d8873356d7e15f843bc523360e206e8e356ff6b82a1fa4b3889dc31d073ea1,6814
pantry-tree:
sha256: 8db12c1f6965d9f0898f04d7b5f1d77682c8ab2d5c394c4a431229df7c4acb14
size: 6231
original:
hackage: hspec-core-2.11.7@sha256:90d8873356d7e15f843bc523360e206e8e356ff6b82a1fa4b3889dc31d073ea1,6814
- completed:
hackage: hspec-discover-2.11.7@sha256:6307eb16d308258a99a242025df50217d835ba0a3f205b1202a100a175877b38,2169
pantry-tree:
sha256: 141b4987d519ad1ca1114737f510f20adc2456bf44c040f41a63792f47d009eb
size: 829
original:
hackage: hspec-discover-2.11.7@sha256:6307eb16d308258a99a242025df50217d835ba0a3f205b1202a100a175877b38,2169
- completed:
hackage: hspec-expectations-0.8.4@sha256:4237f094a7931202ff57ac6475542b0b314b50a7024550e2b6eb87cfb0d4ff93,1702
pantry-tree:
sha256: 87681840d430b84686f83f1ab8b5873b09c349775698665233443914acf9ba2b
size: 741
original:
hackage: hspec-expectations-0.8.4@sha256:4237f094a7931202ff57ac6475542b0b314b50a7024550e2b6eb87cfb0d4ff93,1702
snapshots:
- completed:
sha256: 5a59b2a405b3aba3c00188453be172b85893cab8ebc352b1ef58b0eae5d248a2
Expand Down
2 changes: 1 addition & 1 deletion stack.9.4.7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packages:
extra-deps:
- monad-schedule-0.1.2.1@sha256:95d6b9c6fd36f585e4a52938ebd1762c2e2caa8bb3c11ce86985dd11a2caae1a,1776
- terminal-0.2.0.0@sha256:de6770ecaae3197c66ac1f0db5a80cf5a5b1d3b64a66a05b50f442de5ad39570,2977
- monad-bayes-1.1.1
- monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
- hspec-2.11.7@sha256:2869580a2a29e7beb6268ea3dc561583f4ae229ed1f47fb1c92e8c09ce35acec,1763
- hspec-core-2.11.7@sha256:90d8873356d7e15f843bc523360e206e8e356ff6b82a1fa4b3889dc31d073ea1,6814
- hspec-discover-2.11.7@sha256:6307eb16d308258a99a242025df50217d835ba0a3f205b1202a100a175877b38,2169
Expand Down
8 changes: 4 additions & 4 deletions stack.9.4.7.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ packages:
original:
hackage: terminal-0.2.0.0@sha256:de6770ecaae3197c66ac1f0db5a80cf5a5b1d3b64a66a05b50f442de5ad39570,2977
- completed:
hackage: monad-bayes-1.1.1@sha256:d76401f5b7bdcfe0b454f63f932c97049d633ef2623f19981bba02c63af3a16c,6292
hackage: monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
pantry-tree:
sha256: bf2bdaaf51aaa9b24b3ec3757d83db0e9f5507435984a452788e71cc2bd3b9b7
size: 3567
sha256: ce4a9db9888b589ae56493862ae62f2efb5af8d17d3d55bac0b3f59177881b2b
size: 3823
original:
hackage: monad-bayes-1.1.1
hackage: monad-bayes-1.2.0@sha256:bf83cf8e6d163c461b9964dbff48d4476b2a82421962af317b3a3d0d738ea2a2,6456
- completed:
hackage: hspec-2.11.7@sha256:2869580a2a29e7beb6268ea3dc561583f4ae229ed1f47fb1c92e8c09ce35acec,1763
pantry-tree:
Expand Down