Expected Sample Size

10 views
Skip to first unread message

Michele

unread,
Feb 5, 2024, 9:21:35 AM2/5/24
to webppl-dev
Hello,
I wonder if in webPPL there is a method to directly obtain the Expected Sample Size (ESS) of the particles' weights {w_i} at the end of a SMC simulation.  

ESS=(\sum_i w_i)^2 / (\sum_i w_i^2).

Thanks,
Michele

null-a

unread,
Feb 5, 2024, 10:32:14 AM2/5/24
to webppl-dev
I don't recall a built-in way of getting at this, but I could be wrong.

SMC does resampling, which I think means that in the end each particle has the same weight:


This (or rather the log of it) is available as the `normalizationConstant` property on the returned distribution:


So, perhaps you can use this to compute ESS like so?

```
N = 100;
var dist = Infer({particles: N, ...});
var w_i = Math.exp(dist.normalizationConstant);
var ess = ((N*w)^2) /  (N*(w^2))
```

This is completely untested and I'm not at all confident that it's correct, but perhaps it will help!

Best,

Paul
Reply all
Reply to author
Forward
0 new messages