Skip to content

Commit

Permalink
Report Rhat for the nearly-nonidentifiable experiment.
Browse files Browse the repository at this point in the history
  • Loading branch information
pawel-czyz committed Apr 19, 2024
1 parent 5425510 commit 7a1e616
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions workflows/nearly_nonidentifiable.smk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ---------------------------------------------------
# - Experiment with a nearly non-identifiable model -
# ---------------------------------------------------
from contextlib import redirect_stdout
from dataclasses import dataclass
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -72,12 +73,19 @@ rule generate_data:

rule run_mcmc:
input: "data/{setting}-{seed}.joblib"
output: "samples/MCMC/{setting}-{seed}.npy"
output:
array = "samples/MCMC/{setting}-{seed}.npy",
convergence = "samples/MCMC/convergence/{setting}-{seed}.txt"
run:
data = joblib.load(str(input))
estimator = algo.DiscreteCategoricalMeanEstimator()

estimator = algo.DiscreteCategoricalMeanEstimator(params=algo.SamplingParams(chains=4))
samples = np.asarray(estimator.sample_posterior(data)[estimator.P_TEST_Y])
np.save(str(output), samples)
with open(output.convergence, "w") as fh:
with redirect_stdout(fh):
estimator.get_mcmc().print_summary()

np.save(output.array, samples)


def _bootstrap(rng, stat: dc.SummaryStatistic) -> dc.SummaryStatistic:
Expand Down

0 comments on commit 7a1e616

Please sign in to comment.