Bayesian Inference: From World Cup To Financial Market

 The article was written by Hieu Nguyen, a Financial Analyst at I Know First.



  • Basic Understanding about Bayes’ Theorem
  • Bayesian Inference and World Cup
  • Financial application of Bayesian inference

Bayes’ theorem and Bayesian inference has long been an interesting topic for all of the mathematician and data scientist. It seems to be a very difficult topic and difficult to apply in real world. However, this article will walk you through basic concepts of Bayesian inference and how it can be applied in both soccer and financial world.

Basic Understanding about Bayes’ Theorem

Bayes’ theorem is a formula that describes a probability of an event that is updated by the probability of given conditions. The given conditions may come from common knowledge or historical statistical data. For instance, if we know that one of the reason for lung cancer is smoking, knowing whether a person smoke will help us to provide a better diagnosis. Intuitively, if we know that a person smoke, we are more likely to guess that he/she has lung cancer. In order to understand the Bayes’ theorem, we need to understand the following probabilities concepts:

Probability concepts

Conditional probability (P(A|B)) is the probability of an event (A) given that another event (B) has happened. Let’s take an example. Supposed that you raise 10 cats in your house with the following distribution:

Joint probability P(A and B) is the probability of two events happening together and at the same time. Come back to the previous example, the probability that a cat is white and male is P(white and male) = P(white|male) * P(male) = 2/5 * 1/2  = 1/5. Note that P(A and B) = P(B and A). We can see that P(male and white) = P(male|white) * P(white) = 1/3 * 3/5 = 1/5.The probability that a cat is male given it is black is P(Male | Black) = 3/4 = 75%. Note that the P(A|B) is not equal to P(B|A). For instance, we can see that P(Black|Male) = 3/5 = 60%. Another good example is the probability that an animal has 4 legs given that it is a dog is very high, maybe higher than 90%. However, the probability of that an animal is a dog given that it has 4 legs is very low. It can be a cat, a horse, or an elephant.

P(A and B) = P(A|B) * P(B)

Marginal probability (P(A)) is the probability of the variables contained in the subset of the whole population. For example P(white) = P(white and male) + P(white and female) = 1/5 + 2/5 = 3/5

P(A) = P(A and B) + P(A and not B)

Bayes’ Formula

Now, let’s come back to the Bayes’ formula. As we can see

P(A and B) = P(A|B) * P(B) and P(B and A) = P(B|A) * P(A)

Also, P(A and B) = P(B and A)

Hence, Bayes states a formula

In this formula, P(A) is called prior probability, which refers to the probability that event A happens before we observe B. P(A|B) is posterior probability, which means the probability of event A after we observe B. P(B|A) is the probability of observing B given A, sometimes called likelihood. Hence the Bayes’ theorem helps us to calculate the probability if we have some given inputs.

Bayesian Inference is the process to generate the posterior probability distribution from the prior probability distribution using Bayes’ theorem. In real world, the probability of a prior event will not be described by a single point. Instead, it will be a probability distribution. For instance, the probability of precipitation in December in Israel may be normal distributed at a mean of 30% and the standard deviation of 10%. Also, the probability that the temperature is less than 25°C (77°F) is also normal distributed at 70% and the standard deviation of 5%. Supposed that we wake up a day and know that the temperature is less than 25°C, what is the chance of rain today? The Bayesian inference will help us to answer this question by generating the posterior probability distribution. Later, we will take an example to understand more about the Bayesian inference. But first, let’s have a look at how Bayes’ theorem can be applied.

An example of Bayes’ Theorem

In order to understand the Bayes’ theorem, we will take another example. Supposed that your city has 5 million people, of whom 1,000 have cancer. A doctor from your city invented a cancer test. He said that the accuracy of the test is 99%. One day, you decided to take the test and got a positive result. Should you be worry about that? Let’s have a closer look at the result

Let’s say B is the test result (positive or negative), while A is whether you have cancer or not (cancer or no cancer). Since the accuracy of the test is 99%. P(positive|cancer) = P(negative|no cancer) = 99%.

In fact, the probability that you actually have cancer is only 2%. Yes, only 2%. The result is really counter-intuitive. Looking at the diagram, we can see that one of the main reason is that the number of people that have positive test without cancer (49,990) outweighs the number of cancer patients that have positive test (990).

We will now have a closer look at our result. Supposed that you only know the probability of cancer in your city is 0.02%, your best guess would only be 0.02%. Now, considered the opposite that you only know the accuracy of the test is 99%, and you got a positive test, your best guess know will be 99%, which is very scary. However, if you have both of the information, your prediction is 1.94%, in the middle of the two previous predictions. That’s the reason why we can call this method a shrinking method as it shrinks our prediction based on observation toward the prior mean.

Bayesian Inference and World Cup

(Source: Wikimedia Commons)

There is a lot of application of Bayesian inference in real world. Since the World Cup is happening in Russia, it’s a good time to see how Bayesian inference can be used to predict player’s performance. 4 years ago, in World Cup 2014, James Rodriguez, a Colombian player won the golden boot for the best goal scorer of the tournament. He scored 6 goals out of 17 shoots, with the rate of 35.3%. This rate is sensational if we look at the conversion rate of Cristiano Ronaldo, and Lionel Messi. Both players have won 5 Ballon D’or, the award for the best soccer of the year.

Applying Bayesian Inference

Let’s use Bayes’ inference to make our prediction. First of all, based on the statistic of conversion rate in three best leagues in the world: Premier League (UK), Bundesliga (Germany), and La Liga (Spain). With 412 data points of player who has more than 30 shots, we can see that conversion rate is normal distributed with the mean of 14.31% and the standard deviation of 5.99%. It makes our last prediction seems extremely abnormal. James Rodriguez’s ratio is more than 3 standard deviations away from the mean. It means he’s among 0.27% best players in the world.Does that number mean James Rodriguez is a talent player? If we just look at the number in World Cup 2014, the best prediction for James’ conversion rate at is 35.3%. Applying the central limit theorem, we may have the standard deviation of 11.59%. However, the prediction seems ridiculously high.

Supposed that p is the intrinsic talent of a random player, p should follow a normal distribution. In this case, p is the prior probability

p ~ N(14.31%, 5.99%)

Now, considered the observed value of 17 shots in World Cup 2014, let’s say O. Using central limit theory, the conversion rate of James is a normal distribution with the expected value of p and the standard deviation of 11.5

O|p ~ N(p, 11.59%)

Applying the Bayesian two stage formula, we can end up with a prediction for the posterior probability. The performance of James will follow a normal distribution with the expected value and the standard deviation as follow:

Meaning of the prediction

This prediction is actually better than the previous one since the standard deviation is only 5.32%. In fact, James Rodriguez’s performance in the next 4 years has proved the Bayes’ prediction.

The average in the next 4 years is 20.95%, 0.42 standard deviation away from the Bayes’ prediction. However, if in World Cup 2014, some teams are interested in the ratio of James and want to trade him, should we sell him? In fact, Real Madrid, one of the best soccer clubs in the world, bought him for more than $70 million. 3 years later, he left Real Madrid as a loan to Bayern Munich. Of course, soccer is not all about probability and we cannot conclude that the decision to buy James is a wrong one. However, we now see how Bayesian Inference can be applied an area seem unrelated.

Financial application of Bayes’ theorem

Supposed that we collect the historical data as above. If we do not have any other information, our best guess for the increase of the stock market is 58.33% (1,400/2,400). Today, we know that the interest rate increases, the Bayes’ theorem give us a posterior probability as follow:

Moreover, as we can generate a distribution for interest rate as well as other inputs, we can apply the Bayes’ inference to create a distribution for our prediction. Companies like I Know First even take one step further by applying Bayes’ inference into their artificial intelligence model. I Know First’s AI Algorithms take the parameters of different variables as an input. After applying the Bayes’ inference to the weight of each neuron in the neural network, the Algorithms come up with the forecast including a signal and a predictability for the market. The machine learning algorithms based on thousands of inputs has helped the company to recognize the most important elements for stock market movements


Bayesian inference is a method to update a probability distribution of an event as more data is collected. Bayesian inference are used in many areas in real life ranging from cancer screening, sport, to finance. I Know First is one of the very few companies that has applied Bayesian inference into machine learning algorithm. Currently, the company has successfully generated forecast for more than 10,000 assets all over the world.

To subscribe today and receive exclusive AI-based algorithmic predictions, click here