Skip to content

Commit daeae19

Browse files
committed
fix tut 15
1 parent 0477825 commit daeae19

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tutorials/15_importance_sampled_posteriors.ipynb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@
5858
"from torch import ones, eye\n",
5959
"import torch\n",
6060
"from torch.distributions import MultivariateNormal\n",
61-
"import matplotlib.pyplot as plt\n",
6261
"\n",
6362
"from sbi.inference import NPE, ImportanceSamplingPosterior\n",
6463
"from sbi.utils import BoxUniform\n",
65-
"from sbi.inference.potentials.base_potential import BasePotential\n",
6664
"from sbi.analysis import marginal_plot"
6765
]
6866
},
@@ -71,7 +69,7 @@
7169
"id": "4808d6d3-cb14-4ecd-a0f5-824bf54a5b01",
7270
"metadata": {},
7371
"source": [
74-
"We first define a simulator and a prior which both have functions for sampling (as required for SBI) and log_prob evaluations (as required for importance sampling)."
72+
"We first define a simulator and a prior which both have a `sample` function (as required for `sbi`) and `log_prob` evaluations (as required for importance sampling)."
7573
]
7674
},
7775
{
@@ -202,9 +200,16 @@
202200
"id": "7150cc13-9911-4656-936f-9cafb867eba4",
203201
"metadata": {},
204202
"source": [
205-
"With the SBI toolbox, importance sampling is a one-liner. SBI supports two methods for importance sampling:\n",
206-
"- `\"importance\"`: returns `n_samples` weighted samples (as above) corresponding to `n_samples * sample_efficiency` samples from the posterior. This results in unbiased samples, but the number of effective samples may be small when the SBI estimate is inaccurate.\n",
207-
"- `\"sir\"` (sampling-importance-resampling): performs rejection sampling on a batched basis with batch size `oversampling_factor`. This is a guaranteed way to obtain `N / oversampling_factor` samples, but these may be biased as the weight normalization is not performed across the entire set of samples."
203+
"With the `sbi` toolbox, importance sampling is a one-liner. `sbi` supports two methods\n",
204+
"for importance sampling:\n",
205+
"- `\"importance\"`: returns `n_samples` weighted samples (as above) corresponding to\n",
206+
" `n_samples * sample_efficiency` samples from the posterior. This results in unbiased\n",
207+
" samples, but the number of effective samples may be small when the `sbi` estimate is\n",
208+
" inaccurate.\n",
209+
"- `\"sir\"` (sampling-importance-resampling): performs rejection sampling on a batched\n",
210+
" basis with batch size `oversampling_factor`. This is a guaranteed way to obtain `N /\n",
211+
" oversampling_factor` samples, but these may be biased as the weight normalization is\n",
212+
" not performed across the entire set of samples."
208213
]
209214
},
210215
{

0 commit comments

Comments
 (0)