|
129 | 129 | " Beta(torch.tensor([2.0]), torch.tensor([2.0])),\n",
|
130 | 130 | " ],\n",
|
131 | 131 | " validate_args=False,\n",
|
132 |
| - ")" |
| 132 | + ")\n", |
| 133 | + "prior_transform = mcmc_transform(prior)" |
133 | 134 | ]
|
134 | 135 | },
|
135 | 136 | {
|
|
184 | 185 | "true_posterior = MCMCPosterior(\n",
|
185 | 186 | " potential_fn=BinomialGammaPotential(prior, x_o),\n",
|
186 | 187 | " proposal=prior,\n",
|
187 |
| - " theta_transform=mcmc_transform(prior, enable_transform=True),\n", |
| 188 | + " theta_transform=prior_transform,\n", |
188 | 189 | " **mcmc_kwargs,\n",
|
189 | 190 | ")\n",
|
190 | 191 | "true_samples = true_posterior.sample((num_samples,))"
|
|
228 | 229 | "x = mixed_simulator(theta)\n",
|
229 | 230 | "\n",
|
230 | 231 | "# Train MNLE and obtain MCMC-based posterior.\n",
|
231 |
| - "trainer = MNLE()\n", |
| 232 | + "estimator_builder = likelihood_nn(model=\"mnle\", log_transform_x=True)\n", |
| 233 | + "trainer = MNLE(proposal, estimator_builder)\n", |
232 | 234 | "estimator = trainer.append_simulations(theta, x).train()"
|
233 | 235 | ]
|
234 | 236 | },
|
|
610 | 612 | }
|
611 | 613 | ],
|
612 | 614 | "source": [
|
613 |
| - "estimator_builder = likelihood_nn(model=\"mnle\", z_score_x=None) # we don't want to z-score the binary data.\n", |
| 615 | + "estimator_builder = likelihood_nn(model=\"mnle\", log_transform_x=True)\n", |
614 | 616 | "trainer = MNLE(proposal, estimator_builder)\n",
|
615 | 617 | "estimator = trainer.append_simulations(theta, x).train()"
|
616 | 618 | ]
|
|
847 | 849 | "\n",
|
848 | 850 | "fig, ax = pairplot(\n",
|
849 | 851 | " [prior.sample((1000,))] + posterior_samples,\n",
|
850 |
| - " # points=theta_o,\n", |
851 | 852 | " diag=\"kde\",\n",
|
852 | 853 | " upper=\"contour\",\n",
|
853 | 854 | " diag_kwargs=dict(bins=100),\n",
|
|
0 commit comments