**Bayesian vs frequentist inference and the pest of premature interpretation.**

Brace yourselves, statisticians, the Bayesian vs frequentist inference is coming!

Consider the following statements.

*The bread and butter of science is statistical testing.**It isnât science unless itâs supported by data and results at an adequate alpha level.**Statistical tests give indisputable results.*

One of these is an imposter and isnât valid. â*Statistical tests give indisputable results.*â This is certainly what I was ready to argue as a budding scientist. But the wisdom of time (and trial and error) has drilled it into my head that statistics is only a tool, and itâs up to the scientist to make the decisions that will determine the final result.

And in naive hands, statistics is a tool with the power to rig things up profoundly.

That said, I felt itâs my duty to revisit the topic of a not so well-known statistical phenomenon which illustrates just how much statistics is only a tool. To all aspiring and seasoned data scientists, I present to you: Lindleyâs paradox.

Lindleyâs paradox can be considered the battleground where Bayesian vs frequentist reasoning ostensibly clash. The paradox generally consists in testing a highly-defined H_{0} against a broad-termed H_{1} using a large, LARGE dataset, and observing that the frequentist approach strongly rejects the null, while the Bayesian method unequivocally supports accepting the same null… or vice versa.

Uh-oh.

But fear not, dear reader. Hereâs how weâll approach the problem:

1. A quick refresher on Bayesian theory

2. An intuitive example of Lindleyâs paradoxâŚ with numbers and Greek letters

3. âIs Lindleyâs paradox a paradox?â: a discussion

4. Implications for the data scientist

**The ABCs of Bayesian theory**

Meet Alex Soos. Alex is a bright little girl, aged 11. She wakes up one day and feels a strange tingling sensation in her stomach. Itâs not quite as if sheâs ill; she isnât sure how to describe it. Like a bright yellow light in her stomach, maybe.

She goes to her parents and tells them, looking for an explanation. Mid-discussion the three of them are distracted by a faint tap on the kitchen window. Itâs a dusty grey owl, and itâs looking right at Alexâs family.

âMum, dad, look, it has a letter on its leg!â Alex chortles, almost forgetting the sensation in her stomach.

The letter states:

Alex starts to tremble all over.

âCan this be true, Mum? Dad?â she asks, terrified of the unknown future a magical identity holds.

Alexâs parents exchange meaningful looks. âWellâ, Dad starts, a twinkle in his eye, âyouâve read the probability theory textbook Grandpa gave you for Christmas, you tell us.â

âFrom what we know, wizardry is extremely rare in the general population. Only 0.1% of people have magical powers.â, Mum adds.

âFurthermore, the Hogwarts letters reach the correct recipient 99% of the time. However, the remaining 1% of the time, these letters end up somewhere in the non-magical world, perplexing little girls and boys like yourself.â Dad checks in again.

**âSo, you mean to tell me that there is a 99% chance I am a witch?â screams in indignation Alex.**

âNo, chicken, we just gave you the likelihoods, now you need to figure out the probability that you are a witch, given that you received a Hogwarts letter just now.â Mum explains, patiently.

**âOhâŚ right. Okay. Bayes’ theorem will give me the probability that a hypothesis is true, given an event.â **

Alex recites the rule out of memory. âMy hypothesis here is â*I am a witch*â, and the event: receiving the Hogwarts letter. So, the probability that I am a witch is conditional upon the probability of me receiving a letter.â

Alexâs parents are struck speechless. She is only 11! Alex, on the other hand, is blissfully unaware of her surroundings and deeply engaged with complex mental math.

âTo find out this probability, I need to take the **prior probability** of being magical (that is, the likelihood I am a witch before receiving the letter), and multiply that by the **probability** of the **event**, given the **hypothesis**Â is **true** (that is, the probability of getting the letter, given that I really am magical).â

âThenâ, Alex continues, âI need to divide all this by the **probability of the event** happening (that is, receiving the letter). To get there, I must calculate the probability of being magical **and** receiving the letter, and not being magical **and** receiving the letter by mistake. Right.â

Substituting these with the actual numbers gives Alex a much less confusing mental picture. Alex had read that figuring out the prior probability of things is the most difficult part, but in this case, it was easy: itâs the frequency of witches and wizards in the population, or 0.1%. And, since she already knew, because her parents had told her earlier, that the likelihood of a Hogwarts letter reaching the correct recipient is 99%, the rest was easy.

âI guess the probability of being a witch, given the letter has been received, is

which amounts to a 9% chance.’

#### Odd.

**âSo… the chance of me being a witchÂ ****after receiving the letter is actually only 9%?â **Alex asks, surprised by the power of Bayesian inference to provide perspective.

âYep. So, no need to worry yet, chicken.â Says Mum.

Cool. Now that we have the example ready, letâs snap back into the actual lesson of the article. Here are the key takeaways from the example.

First, **what the numbers tell us makes sense**. If Alex took 1000 people, only 1 would be a wizard and will have received their letter. Another 10, however, would have received a letter even though they are not magical. So, the chances Alex is a witch and has received her letter correctly are 1 in 11 (or 9%).

Second, if stripped down to its core, **Bayes theorem is about updating our beliefs when new evidence becomes available**. This means that it is best used *many* times: the more evidence, there is, the more accurately whatever result you get will reflect the state of things. Let me explain.

**Some terminology: the posterior and the prior.**

The *posterior* is what you are trying to determine. It is the probability of an event occurring after some evidence has been taken into account; like in the example, the probability Alex is a witch, given that she received a letter by owl. The posterior has a fun relationship with the prior. If new evidence comes into play, the last posterior you have becomes the new prior.

For example, if Alex were to receive a *second* letter reminding her she still hasnât responded to the first one, the probability of Alex being a witch would look like this:

#### Substitute with the numbers, it looks like this:

Did you notice that we used the probability of Alex being a witch which we determined when the first letter arrived as our prior, and calculated the new posterior probability of her being a witch, given that a second letter has arrived? Good noticing!

#### So, whatâs the big deal about the *prior*?

The prior probability, or in our example the prior belief that Alex could be a witch before receiving the letter, is the initial degree of belief about the likelihood of an event, before considering the latest available evidence. The prior is kind of the powerhouse of Bayesian inference. Think of it this way: you are playing bowling, but youâre blindfolded. You release the ball and it hits the pins somewhere (in the middle, or towards the left edge, or towards the right). The point is, with each new release of the ball you get an increasingly more accurate representation of your initial bowl. In other words, you get an increasingly more informative posterior. And the prior? The prior is where you believe the ball hit, before each new release. Itâs the last posterior you reached before considering the newest bowl.

**This is all fairly straightforward. But…**

**Problems begin to arise when the previous posterior probability hasnât been calculated**

or isnât known to the researcher, making setting a prior more difficult. This is where parameter estimation comes to the rescue. There are dozens of methods to estimate a prior. Itâs beyond the scope of the article to review them, but Iâll just mention some of the most frequently used ones.

**Use your understanding of the matter to propose a prior that is intuitive and reasonable.**

This is a non-sophisticated approach but with careful sensibility and robustness analyses can yield reliable results.

**Derive a non-informative prior, or use a prior distribution that is already available.**

Non-informative priors are increasingly popular in Bayesian analysis. They provide an appearance of objectivity, as opposed to priors that are subjectively elicited. A non-informative prior gives a very general information about a variable; the best-known rule for determining a prior like this is the **principle of indifference**, where all possibilities are assigned equal probabilities. Remember this one, weâll use it in a minute.

For a more in-depth discussion of non-informative priors, have a look at this passage, and this catalogue.

Wait. We can choose our own priors? But canât this bias our results?

Absolutely. See, the beauty of Bayesian inference is that *our actions play a role in determining the outcome and ultimately how we interpret the world*. Sometimes, if you are an evil scientist, this also means you can use Bayesian inference to âlie with statisticsâ. (For a neat little way this happens in frequentists statistics, too, see Simpson’s paradox).

**Because Bayesâ theorem doesnât tell us how to set our priors, paradoxes can happen. **

**Lindleyâs paradox: the example**

**Now that weâve brushed over our Bayesian knowledge, letâs see what this whole Bayesian vs frequentist debate is about. Itâs time to dive into Lindleyâs paradox.**

Letâs say you are flipping a coin, and you have endless patience. You get 1,000,000 flips (*N* = 1,000,000), of which 498,800 are heads (*k* = 498,800), and 501,200 are tails (*m* = 501,200). You want to test whether the coin youâre using is fair. Coin flipping is a canonical binomial example, so we can assume that the number of times we got heads is a binomial variable (actually we are in the special case of the Bernoulli distribution).Â We can give it the parameter Î¸ (you can also call it x, y, z, or Bob, if you want, it doesnât matter). Your hypothesis is that the coins are unbiased, therefore Î¸ = 0.5.

So, H_{0}: The coins are fair.

HÂ_{1}: The coins are not fair.

And as any good statistician following the Bayesian method would, you will reject this hypothesis if statistical testing tells you the probability of the result is less than 5%. Similarly, following the frequentist school of thought, you would ask yourself âwhat is the probability of getting the number of tails I got, given Î¸ = 0.5. If your result is less than 5%, you will again reject the null, that is, that the coins are fair. (You might also like our piece on Type I vs Type II errors and the importance of defining your H_{0} well.)

**If you put your Bayesian statistician hat on for the analysis, you will need to define your prior.**

As mentioned above, a non-informative prior can be considered the most objective option, so you do that. You define your prior to assign equal probabilities to all possibilities. So, it will be equally possible for Î¸ = 0.5, and Î¸ â 0.5. In other words, the *P(H _{0})* =

*P(H*= 0.5. Cool? Cool.

_{1})Then, the posterior probability of our hypothesis (H_{0}) given the number of heads observed, is the following:

To get all the parameters, you need to calculate the *P(k | H _{0})* and

*P(k | H*, which can be done with a probability mass function for a binomial variable. The math looks like this:

_{1})Donât worry if not everything makes perfect sense, there is plenty of software ready to do the analysis for you, as long as it has the numbers, and the assumptions.

Finally, inputting all values into the equation, we get a posterior probability for H_{0} â 0.98. This is an exceptionally large probability and it definitively supports H_{0}: the coins are unbiased, and Î¸ is indeed 0.5; the data is unequivocal.

Sweet.

**Now, letâs do the same but while wearing our frequentist statistics hat.**

Remember, the H_{0} is that Î¸ = 0.5, and we reject it if there is less than 5% chance of getting the number of heads we got, given H_{0}.

We assume the data are *normally* *distributed* because with a sample this big (*N* = 1,000,000) this is the natural assumption, following the central limit theorem.

The assumption of normality still holds, so we calculate a simple two-sided probability value, like this:

Oh, no. The p-value is highly significant. There is less than 2% probability to get the number of heads we got, under H_{0} (by chance). The frequentist scientist in you screams REJECT THE NULL, whereas the Bayesian theorist passionately urges you to ACCEPT THE NULL.Â The Bayesian vs frequentist clash in action!

While you stare at the results wide-eyed, Lindleyâs paradox sniggers quietly in the dark.

But how â why â does this happen?

## Â .**Lindleyâs paradox explained**

Lindleyâs paradox can equally well be known as the paradox that isnât a paradox at all. Thatâs right, Lindleyâs paradox is a misnomer. Why?

**Because the question that the Bayesian approach answers, and the one the frequentist approach answers, are different. **

Do you remember how we defined the null? For H_{0} we chose Î¸ = 0.5. We can agree that this is highly specific. On the other hand, for H_{1}, or the alternative, we failed to provide any specification; we decided Î¸ â 0.5 sufficed. However, that means that Î¸ can be anywhere in the [0,1] range.

The implications of this decision become clearer when you think of the posterior probabilities of Â *P(k | H _{0})* and

*P(k | H*. How likely is it to see 498,800 heads in a 1,000,000 coin flips?

_{1})Under H_{0}, Î¸ assumes the value of 0.5.

Under H_{1}, we choose Î¸ to be any number between 0 and 1.

Now, the ratio of heads observed is 0.498.Â This is very close to the value of Î¸ under the null. On the other hand, the majority of possible values for Î¸ under the alternative hypothesis are far from 0.498. In other words, the data doesnât support the diffuse alternative, in light of the tightly defined null. The posterior probability of *P(k | H _{0})*Â is a lot larger than the posterior probability of

*P(k | H*.

_{1})Alright, this explains why the Bayesian inference strongly favours the null.

**But why does the frequentist method reject it? **

At the core of the Bayesian vs frequentist problem is that the frequentist approach considers only the null. The probability test doesnât make reference to the alternative hypothesis. Therefore, in essence, the frequentist approach only tells us that the null hypothesis isnât a good explanation of the data, and stops there.

And thatâs your answer!

While under the frequentist approach you get an answer that tells you H_{0} is a bad explanation of the data, under the Bayesian approach you are made aware that H_{0} is a much better explanation of the observations than the alternative.

**See? Lindleyâs paradox is no paradox at all, and the Bayesian vs frequentist clash isnât really a clash â it just showcases how two methods answer different questions.Â **

_{Â }

**Implications of Lindleyâs paradox for the data scientist**

There are a couple of things I must point out about Lindleyâs paradox.

First, the paradox in part arises because large data is oversensitive to very simple frequentist analysis, like rejecting a null. That said, it teaches us that large data is not the save-all messiah of statistical testing. Choosing the right statistics to calculate, and making the correct assumptions is.

Second, it is possible to sidestep Lindleyâs paradox by defining a prior distribution that will yield the same results the frequentist approach does, but what will that teach us? The two methods â Bayesian vs frequentist â answer different questions, and are driven by different assumptions. As simple as that.

Again, if you want to become a successful data scientist, always think twice and three times what exactly you want to learn and whether your test will be adequate for answering your questions.Â

### And finally, be wary of over specifying your hypotheses, and, conversely, making predictions that are too vague.

If Lindleyâs paradox has taught us anything (okay, it teaches us many things), is that defining a hypothesis like this H_{0 }= A, and the alternative as H_{1} â A, is not good. What you are aiming to do is be in a state of balance: H_{0 }= A, whereas H_{1} = B.

Okay, thatâs Lindleyâs paradox covered, the Bayesian vs frequentist reasoning refreshed on. Now that you warmed up your analytical reasoning, give our Simpson’s paradox article a go.

Good reading, scientists!

I have read this post with interest, but I am confused by the Hogwarts example, specifically with the probability of the little girl receiving a letter by mistake. Let’s say that the total population is given by N, and the number of witches in the population is W, so that w = W/N = 0.001. If I understand the premise correctly, Hogwarts sends W letters to its potential witches, of which a proportion p (=0.99) reach a wizard correctly. In other words, p times W letters reach a wizard, and so (1-p)W letters reach non-wizards. So the probability that a given individual in the non-wizard population receives a letter erroneously should equal the number of letters reaching non-wizards, divided by the total number of non-wizards. This gives a probability of (1-p)W/(N-W) = (1-p)w/(1-w) which is very close to (1-p)w = 0.00001, since w << 1. This is quite smaller than 1-p = 0.01, the figure stated in the article.

This makes sense, since for 1% of the non-wizard population to receive a letter erroneously, Hogwarts would need to sent 10 times more letters than there are witches (0.1% of the population) from the start, and all those letters need to land erroneously in the non-wizard population. This does not seem to be the situation described in the article, where Hogwarts and the owls seem to be very accurate (likelihood of a letter to correctly reach its target = 99%). It seems to me that either Hogwarts is way more inaccurate than stated and sends out many more letters than there are witches, or the probability of receiving a letter by mistake should be reduced, as calculated above.

If however the probability that a given non-wizard receives a letter erroneously is truly 1%, and the probability that a given wizard has received a letter correctly is truly 99%, then the probability of a given Hogwarts letter to correctly arrive at a wizard is not 99%. It should instead be given by the number of sent letters that reached a wizard, divided by the total number of letters sent : = 0.99*W/[0.99*W + (0.01)*(N-W)] = 0.0902 (approx.). It seems that this is the model that is actually used in the calculations of the article. If that is the case, then I would suggest rewording the problem statement to better describe the true accuracy of Hogwarts, since it is misleading as written.

If my assessment is wrong, I would appreciate any feedback explaining clearly where my interpretation of the problem statement fails. Thank you!