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 ESS thoreshold logic to SMCFilter #2486

Merged
merged 1 commit into from
May 16, 2020
Merged

Conversation

fritzo
Copy link
Member

@fritzo fritzo commented May 16, 2020

Addresses #2426

This adds an ESS-based threshold to SMCFilter to decide when to importance resample (resolving a long-standing TODO). The default is to resample when ESS < num_particles / 2. I've also threaded this through the epidemiological CompartmentalModel because I've found a lower threshold can help preserve diversity and find a feasible solution in #2468.

I've also added a couple checks to raise ValueError asap when SMCFilter fails to find a feasible hypothesis.

Tested

Comment on lines +132 to +135
logp = self.state._log_weights
logp -= logp.logsumexp(dim=-1)
ess = logp.mul(2).exp().sum().reciprocal()
if ess < self.ess_threshold * self.num_particles:
Copy link
Member Author

Choose a reason for hiding this comment

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

Derivation:

ess = 1 / sum(p[i] ** 2 for i in range(N))
    = 1 / sum((logp[i] * 2).exp() for i in range(N))
    = logp.mul(2).exp().sum().reciprocal()

Copy link
Collaborator

@martinjankowiak martinjankowiak left a comment

Choose a reason for hiding this comment

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

👍

@martinjankowiak martinjankowiak merged commit c62842e into dev May 16, 2020
@fritzo fritzo deleted the smc-ess-threshold branch June 5, 2020 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants