Skip to content

Commit 3013206

Browse files
rename log_gamma module to sbc
1 parent 69917fb commit 3013206

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

bayesflow/diagnostics/metrics/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from .expected_calibration_error import expected_calibration_error
55
from .classifier_two_sample_test import classifier_two_sample_test
66
from .model_misspecification import bootstrap_comparison, summary_space_comparison
7-
from .log_gamma import log_gamma, gamma_null_distribution, gamma_discrepancy
7+
from .sbc import log_gamma

bayesflow/diagnostics/metrics/log_gamma.py renamed to bayesflow/diagnostics/metrics/sbc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def log_gamma(
1919
Log gamma is log(gamma/gamma_null), where gamma_null is the 5th percentile of the
2020
null distribution under uniformity of ranks.
2121
That is, if adopting a hypothesis testing framework,then log_gamma < 0 implies
22-
a rejection of the hypothesis of uniform ranks at the 5\% level.
22+
a rejection of the hypothesis of uniform ranks at the 5% level.
2323
This diagnostic is typically more sensitive than the Kolmogorov-Smirnoff test or
2424
ChiSq test.
2525

tests/test_diagnostics/test_diagnostics_metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,20 @@ def run_sbc(N=N, S=S, D=D, bias=0):
108108
ranks = np.sum(posterior_draws < prior_draws, axis=0)
109109

110110
# this is the distribution of gamma under uniform ranks
111-
gamma_null = bf.diagnostics.metrics.gamma_null_distribution(D, S, num_null_draws=100)
111+
gamma_null = bf.diagnostics.metrics.sbc.gamma_null_distribution(D, S, num_null_draws=100)
112112
lower, upper = np.quantile(gamma_null, (0.05, 0.995))
113113

114114
# this is the empirical gamma
115-
observed_gamma = bf.diagnostics.metrics.gamma_discrepancy(ranks, num_post_draws=S)
115+
observed_gamma = bf.diagnostics.metrics.sbc.gamma_discrepancy(ranks, num_post_draws=S)
116116

117117
in_interval = lower <= observed_gamma < upper
118118

119119
return in_interval
120120

121121
sbc_calibration = [run_sbc(N=N, S=S, D=D) for _ in range(100)]
122-
lower_expected, upper_expected = binom.ppf((0.005, 0.995), 100, 0.95)
122+
lower_expected, upper_expected = binom.ppf((0.0005, 0.9995), 100, 0.95)
123123

124-
# this test should fail with a probability of 1%
124+
# this test should fail with a probability of 0.1%
125125
assert lower_expected <= np.sum(sbc_calibration) <= upper_expected
126126

127127
# sbc should almost always fial for slightly biased posterior draws

0 commit comments

Comments
 (0)