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

Add effective sample size to Population #268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

turion
Copy link
Collaborator

@turion turion commented May 10, 2023

I recently read about improving existing resampling methods by only resampling when the effective sample size is small.

Copy link
Contributor

@reubenharry reubenharry left a comment

Choose a reason for hiding this comment

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

I assume this preserves the unbiased nature of SMC (since no resampling is unbiased, and full resampling is unbiased) - if not it should be commented.

Copy link
Contributor

@reubenharry reubenharry left a comment

Choose a reason for hiding this comment

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

I assume this preserves the unbiased nature of SMC (since no resampling is unbiased, and full resampling is unbiased) - if not it should be commented.

@turion
Copy link
Collaborator Author

turion commented May 11, 2023

I assume this preserves the unbiased nature of SMC (since no resampling is unbiased, and full resampling is unbiased) - if not it should be commented.

I'm not sure. Is there a resource to read up about biases introduced by resampling? I didn't read anything in Murphy's book about this not being unbiased. I would have thought that if the procedure at each timestamp is not biased, the whole process is not biased, but I can't prove it.

@turion
Copy link
Collaborator Author

turion commented May 11, 2023

Also, I want to add a fixture test and look at the values a bit before merging.

@reubenharry
Copy link
Contributor

I don't really know, but yeah, I also agree with that reasoning.

@turion
Copy link
Collaborator Author

turion commented May 11, 2023

I managed to produce a crash using this function in rhine-bayes, but I haven't found the reason yet.

@turion
Copy link
Collaborator Author

turion commented May 11, 2023

I managed to produce a crash using this function in rhine-bayes, but I haven't found the reason yet.

The crash was:

rhine-bayes-gloss: Statistics.Distribution.Normal.normalDistr: standard deviation must be positive. Got NaN
CallStack (from HasCallStack):
  error, called at ./Statistics/Distribution/Normal.hs:115:27 in statistics-0.16.2.0-ca3954dbbfc16db2d02d8c716cbf789c747e026d3f9db91380356ec3f9721ef8:Statistics.Distribution.Normal
Segmentation fault (Speicherabzug geschrieben)

I could not manage to reproduce it again. In subsequent runs, it seemed to me that one could definitely speed up performance, while keeping the same variance.

-- | The new resampler
(Population m a -> Population m a)
onlyBelowEffectiveSampleSize threshold resampler pop = do
ess <- lift $ effectiveSampleSize pop
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is wrong because it will execute the m effects of pop again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It might be better to have a function withEffectiveSampleSize :: Functor m => Population m a -> m (a, Double)

@@ -206,6 +208,31 @@ resampleMultinomial ::
PopulationT m a
resampleMultinomial = resampleGeneric multinomial

-- | Only use the given resampler when the effective sample size is below a certain threshold
onlyBelowEffectiveSampleSize ::
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I should have one fixture test and a unit test where this is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants