Our next example is about portfolio optimization. This is pretty much applications in finance, that's the Hofstede. Let's say I now have $100,000 and I'm going to invest that into three different targets. Lets say I have three stocks, stocks one, two and three. I know their current price. Their current price are 50,40 and 25, and I also see their expected future price. For example, maybe today I need to allocate my money to these stocks, I buys several shares from all the stocks, and if I buy one share of stock one, I'm going to pay $50, and after I go to sleep tomorrow, I will see it becomes for example 55 in expectation. Suppose that's the case and I want to maximize my total amount of money for tomorrow in expectation. If I want to maximize my expected profit, how may we allocate my budget? That's the basic setting. Well, this setting is very simple because if I want to maximize my expected profit, we will say xi is the number of share of stock I purchase, and I'm going to formulate the following linear program. What's this? I'm going to say I have a budget constraint because for each share of stock one, I need to pay $50 and so on and so on. Once I can choose the number of shares to be purchased from each stock, I know my expected profit for tomorrow would be 55 times x1 plus 50 times x2 and so on. Once we see that, then very quickly we know how to solve this problem. Obviously, we will spend all our money to purchase stock two, because that's actually the most efficient way to earn some money back. Once we understand that, we know is actually equivalent to just look at the ratios because stock two has the highest return ratio, that's why we are most interested in this particular investment targets. But actually, investment is not so easy because we all know that stock prices cannot be easily predicted, and there is always some kind of risk. I cannot just put all my money to the one with the highest expected return, because typically, if there's one target which has the highest expected return, it would also has high risk. The price may fluctuate a lot. I may actually earn nothing back and that's some trade-off I need to worry about. There are plenty of ways to major risk, and there was some Nobel Economics Prize laureates. They suggests for example, Markowitz and Sharpes. They suggest that if I know the total revenue is random and typically we don't really like randomness, we would use the variance of the revenue to determine or denote the amount of risk. We would say the larger the variance, the higher the risk. In this case, we want to minimize the total variance while ensuring a certain expected revenue. What does that mean? I want to say whether I may earn some money back in expectation while I want to minimize my total variance, I want to use the lowest risk way to guarantee some expected revenue. That's how this may be done. Pretty much we need to first have a way to talk about variants. What's this? We pretty much need to have some review about probability. That's X is our random variable, mu is this expected value, and the xi is the I's possible realization. That save probability for x to be xi is the probability for xi to be the outcome. Then the variance is defining this way. This is the formula for variance. This is not a statistics or probability course, I would assume you know it and it just gives you some interpretation. Pretty much you have one point which is your mu, and you have some other points which we are your x possible realization. We would say the difference between each realization and your mu. If the distance becomes higher, then you say you have a larger variance. If all the possible outcomes are close to your mu, close to your expected value, we say your variance is smaller. If they are actually far from the expected value, we say you have high variance. For each possible value, we get some distance from it to your expected value. For this distance, we square it and then to some weighted average according to the probability, that's variance. This is something that everybody knows, If you get some training about statistics or probability, if you don't, that's also fine. I'll just take this formula as something that you are given. For example lets say the future prices for stock one may be either 65 or 45, each with probability 50 percent. If I buy one share, the variance would be calculated in this way. Buying one share, it gives me either 50 and 65, or 45 for tomorrow, and the expectation is 55, so according to this formula, using 1.5, 1.5 as the weight, I'm going to see 100 is my variance for my revenue. If I buy two shares, then the expectation become 110 and two possible outcomes are 130 and 90. In that case, I'm going to get 400 as my risk or as my variance. In that case, my conclusion would be that if I buy X1 shares, my variance from stock one would be 100 X1 square. In general, if I multiply my random variable by small b, that's small b can be taken outside the variance, but it needs to be squared. That can be true for any possible constant of b. In short, what do we know is that if you buy more, then you get higher-risk because the outcome becomes even more uncertain. It has something to do with this number 100, which is based on the variance if you buy one share, and then if you buy two shares it becomes 400, if you buy three shares they become 900. The risk or the variance increases in a quadratic way. Because you can see in the formula there is a quadratic term. That's pretty much about variants.