From Tossing Coins to Predicting Stock Prices by abdelazizalgh | Jun 27, 2020 | Mathematical Finance, Mathematics, Quantitative Finance The Mathematics of a Coin Toss A coin is a very interesting item. This is because its intriguing aspect truly lies with its use in probability, rather than it’s function as a monetary item. Coins are widely used as a tool to aid in randomly selecting between two choices. What makes a coin perfect for this job is the fact that it has two sides: Heads (H) and Tails (T). The act of tossing a coin is indeed a random experiment. There are realistically only two possible outcomes (binomial probability), either heads or tails. A fair coin is one where the probability of yielding a heads or a tails as an outcome of the random experiment of tossing is 50%. Suppose we were to toss a fair coin once, what is the total outcome (Sample space, S)? S={H,T} How about tossing the coin twice? S={HT, HH, TT, TH} Suppose we tossed the fair coin 12 times and recorded each the outcome each time: H, T, T, H, H, H, T, H, T, T, H, T What if we did that for 100 times: H, T, T, H, H, H, T, H, T, T, H, T, T, H, T, H, … (up to the 100th outcome). Keep in mind, each of the outcomes from S (for one coin toss) have equal chances (50%) of occurring. Let the times a random experiment is repeated be N, which is made up of N discrete steps. By discrete we mean countable. A Simple Game Suppose that you and I wanted to play a game. Basically the game entails the following: If I toss a coin and the outcome is heads, you move to the right Else, If its tails, you move to the left In order to play this game and actually know where you end up (your final position), we will need to define your starting position. By doing so, we’ve specified the origin, and since your movement is either left or right which is one dimensional, we can use the x-axis to determine your final position. Notice that we are pegging the outcome of a fair coin toss to the decision of moving left or right. Now to link that decision to a movement in our x-axis, we will assign values to each outcome of the coin toss as such: Heads = 1 Tails = -1 We will repeat this experiment N times yielding N steps in the game. Also, we shall denote your final position as D: D = x1+x2+x3+…+xN Naturally we ought to ask the question, what is the expected value of your final position D? To answer it we must consider the expected value of each experiment x. Since, we are using a fair coin, each outcome for which there are 2, H or T (translated in our game as left or right), all have a probability of 50% (0.5) of happening. This means that the expected value of one experiment would be: E(x)= [-1*0.5] + [1*0.5] = 0 This means that for each x, from x1 up to xN, the expected value is 0. Hence we can deduce that E(D)= 0, as E(D) is the sum of each individual expected value of each step from x1 up to xN. Linguistically speaking, your expected position after playing this game would be right where you began — at zero. So on average you stayed in the same place. This phenomenon of randomly moving is called a random walk. Coin Toss, Simple Random Walk, and Stock Prices In essence, to play the game we did above, we used a coin toss to model your random movement (left or right). The important point to realize is that we were using a fair coin, with only two possible outcomes with equal probabilities of p=0.5 for H and T and consequently right (+1) or left (-1). This meant that the expected value of D, your final position, would be 0. However, we would like to end up somewhere different than our starting point. To do so, we can define a fixed probability p for H (right (+1)) which subsequently leaves the probability 1-p for T (left (-1)). This bias in probability is called the drift. If p>0.5 then it favors right else if p<0.5 it favors left. We use the same mathematics to figure out the expected value of the final position which either tends more to the left or right depending on the aforementioned conditions. Because this is a much more realistic model of a random walk that reaches somewhere it can be used to predict stock price movements. The assumption here of course, is that the movement in a stocks price is random. Alright, now we will use the more realistic model above and make it even more realistic — however instead of playing the game of dictating whether you move left or right, instead we will model the movement of a stocks price from a starting point that is not 0 (the origin) and the y-axis rather than the x-axis. Also we will record the iterations at time steps from 0 to N. Now let us further develop on this model. How about, instead of fixing the probability p ourselves, we let p be a uniformly distributed random number between 0 and 1 — for which p is repeatedly and randomly selected for each step up to N; if p>0.5 we assign it as heads (H) else if p<0.5 we assign it as tails (T) In the previous ideas of random walks, we considered 1-D movement which was arithmetic. In developing our new model, let us add a factor of proportionality, whereby the value of the current stock price is proportional to the one before and the one to come. How a stocks price change however, is different — owing to p being a uniformly distributed random number at each step. We will therefore alter the model from an arithmetic random walk to a geometric random walk by utilizing these conditions which follow on from the assignment of H or T: if H, then multiply the current stock price by 1.01 else if T, then multiply the current stock price by 0.99 We repeat these steps N times: randomly selecting p, assigning H or T according to p, and then factor multiplication based on H or T. Finally it’s time to apply the model. I will choose Boeing Company stock to simulate its price movement over 100 days using our geometric random walk model. The starting stock price (starting position) at time step 0 is around $158 per share. Using Matlab to code our model and run it, we get: Graph of our geometric random walk model for Boeing Company stock over 100 days Now lets compare it to what actually happened over 100 days from the same starting price: Graph of actual historical prices for Boeing Company stock over 100 days Incredible isn’t it? Interestingly enough the simulated and the actual are both strangely similar. Even their final prices at the end of the 100 days are almost similar (approx.168 and 170). But what is of true importance is the overall price movements — the shape of the graphs are nearly the same. Conclusion Whilst observing the results above, it is important to note, that this is indeed a lucky case. The model is very simple. Nevertheless, this acts as a starting point to begin to model the price movements of many different kinds of financial instruments. The concept of random walks which leads to brownian motion are examples of ideas from mathematics and physics used to model in quantitative finance. Related