13.08.2022 Views

advanced-algorithmic-trading

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

39

We discussed the fact that we could use a relatively flexible probability distribution, the beta

distribution, to model our prior belief on the fairness of the coin. We also learnt that by using

a Bernoulli likelihood function to simulate virtual coin flips with a particular fairness, that our

posterior belief would also have the form of a beta distribution. This is an example of a conjugate

prior.

To be clear, this means we do not need to use MCMC to estimate the posterior in this

particular case as there is already an analytic closed-form solution. However, the majority of

Bayesian inference models do not admit a closed-form solution for the posterior, and hence it is

necessary to use MCMC in these cases.

We are going to apply MCMC to a case where we already "know the answer", so that we can

compare the results from a closed-form solution and one calculated by numerical approximation.

4.5.1 Inferring a Binonial Proportion with Conjugate Priors Recap

In the previous chapter we took a particular prior belief that the coin was likely to be fair, but

that we weren’t particularly certain. This translated as giving the beta probability distribution

of θ a mean µ = 0.5 and a standard deviation σ = 0.1.

A prior beta distribution has two parameters α and β that characterise the "shape" of our

beliefs. A mean of µ = 0.5 and s.d. of σ = 0.1 translate into α = 12 and β = 12. See the

previous chapter for details on this transformation.

We then carried out 50 flips and observed 10 heads. When we plugged this into our closedform

solution for the posterior beta distribution, we received a posterior with α = 22 and β = 52.

Figure 4.1, reproduced from the previous chapter, plots the distributions:

Figure 4.1: The prior and posterior belief distributions about the fairness θ

We can see that this intuitively makes sense, as the mass of probability has dramatically

shifted to nearer 0.2, which is the sample fairness from our flips. Notice also that the peak has

become narrower as we’re quite confident in our results now, having carried out 50 flips.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!