# Bayesian updating formula

The formulas on this page are closed-form, so you don't need to do complicated integral evaluations; they can be computed with simple loops and a decent math library.The advantage of Bayesian formulas over the traditional frequentist formulas is that you don't have to collect a pre-ordained sample size in order to get a valid result.In our case, Pr(X) gets really large because of the potential for false positives.Thank you, normalizing constant, for setting us straight!One of the more machine learning focused talks by Jun Zhu caught my attention with a simple but surprising generalisation of Bayesian updating which he and his co-authors call “Regularized Bayesian Inference” or Reg Bayes.The core idea is very simple: express classical Bayesian updating as an optimisation problem (see below) and then add constraints and regularisers to the posterior distribution.Think of something observable - countable - that you care about with only one outcome or another.

It is the number of votes that your candidate is going to get in that election, the number of free throws the big man makes, the number of cancer patients who survive.

Or a political talking head says that your candidate is going to lose big.

You probably want a way to compare your beliefs with theirs.

Your standard library’s log-beta function will come in handy here.

If you don’t have log-beta available, it's easy enough to define one with the log-gamma function and the identity: \[ \log(B(a, b)) = \log(\Gamma(a)) \log(\Gamma(b)) - \log(\Gamma(a b)) \] If you have neither log-beta nor log-gamma available, first rewrite the equation in terms of gamma function: \[ (p_B p_A) = \sum_^\frac \] Using the property that \(\Gamma(z)=(z-1)!