# urigoren / conjugate_prior

Implementation of the conjugate prior table for Bayesian Statistics
Python Shell Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information. conjugate_prior Aug 21, 2019 .gitignore README.md pypi.sh setup.cfg setup.py

# Conjugate Prior

Python implementation of the conjugate prior table for Bayesian Statistics https://en.wikipedia.org/wiki/Conjugate_prior#Table_of_conjugate_distributions

## Installation:

`pip install conjugate-prior`

## Supported Models:

1. `BetaBinomial` - Useful for independent trials such as click-trough-rate (ctr), web visitor conversion.
2. `BetaBernoulli` - Same as above.
3. `GammaExponential` - Useful for churn-rate analysis, cost, dwell-time.
4. `GammaPoisson` - Useful for time passed until event, as above.
5. `NormalNormalKnownVar` - Useful for modeling a centralized distribution with constant noise.
6. `NormalLogNormalKnownVar` - Useful for modeling a Length of a support phone call.
7. `InvGammaNormalKnownMean` - Useful for modeling the effect of a noise.
8. `InvGammaWeibullKnownShape` - Useful for reasoning about particle sizes over time.
9. `DirichletMultinomial` - Extension of BetaBinomial to more than 2 types of events (Limited support).

## Basic API

1. `model = GammaExponential(a, b)` - A Bayesian model with an `Exponential` likelihood, and a `Gamma` prior. Where `a` and `b` are the prior parameters.
2. `model.pdf(x)` - Returns the probability-density-function of the prior function at `x`.
3. `model.cdf(x)` - Returns the cumulative-density-function of the prior function at `x`.
4. `model.mean()` - Returns the prior mean.
5. `model.plot(l, u)` - Plots the prior distribution between `l` and `u`.
6. `model.posterior(l, u)` - Returns the credible interval on `(l,u)` (equivalent to `cdf(u)-cdf(l)`).
7. `model.update(data)` - Returns a new model after observing `data`.
8. `model.predict(x)` - Predicts the likelihood of observing `x` (if a posterior predictive exists).

## Coin flip example:

``````from conjugate_prior import BetaBinomial