From 442db8a780aeb781bcb39f7bde1a56ce03b4d3c2 Mon Sep 17 00:00:00 2001 From: rnburn Date: Sat, 5 Oct 2024 20:30:12 -0700 Subject: [PATCH] add example --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 8f3e997..063e72f 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,26 @@ See [example/19-hypothesis-first-t.ipynb](example/19-hypothesis-first-t.ipynb) f [example/18-hypothesis-eeibf-validation.ipynb](example/18-hypothesis-eeibf-validation.ipynb) for a step-by-step validation of the method against the paper. +### Objective Bayesian inference for comparing binomial proportions +https://www.objectivebayesian.com/p/binomial-comparison + +Fit a posterior distribution with a reference prior to compare binomial proportions: +```python +from bbai.model import DeltaBinomialModel + +# Some example data +a1, b1, a2, b2 = 5, 3, 2, 7 + +# Fit a posterior distribution with likelihood function +# L(theta, x) = (theta + x)^a1 * (1 - theta - x)^b1 * x^a2 (1-x)^b2 +# where theta represents the difference of the two binomial distribution probabilities +model = DeltaBinomialModel(prior='reference') +model.fit(a1, b1, a2, b2) + +# Print the probability that theta < 0.123 +print(model.cdf(0.123)) + # Prints 0.10907436812863071 +``` ### Efficient approximation of multivariable functions using adaptive sparse grids at Chebyshev nodes. ```python