Now, let's see how we should compute optimal hedges. That is optimal positions in this stock in all possible states of the work at time t. So, how can we do this? In the previous video, we computed the portfolio value using the pathways evaluation on Monte Carlo path. Now, to compute optimal hedges Ut, we need to look at all Monte Carlo paths simultaneously. The other name for this is the cross-sectional analysis. So, we need to do a cross-sectional analysis from all Monte Carlo paths to find optimal hedges. Why is it so? This is simply because each Monte Carlo path gives us only one value as a time t. But a hedging strategy used here should apply to all states that might be encountered in the future. Therefore, to compute an optimal hedge Ut for a given time step t, we need the cross-sectional information on Monte Carlo path at this time. Okay. So, the first point to make here is that we have to look at all Monte Carlo paths at once. The second question is, what time order we should compute optimal hedges? We will do that work in time starting from the final time t equal to T. This is similar to the portfolio value calculation that we did in the previous video. However, because we can't know the future when we compute the hedge, for each time t, we should condition on their information Ft, that is available at time t. Doing otherwise would be equivalent to peaking into the future. The information set F t includes histories of individual Monte Carlo paths up to and including time t. And in addition, F t may include some market factors that can impact stock prices. Now, let's see how we can compute the optimal hedges u*. We obtain the optimal hedge u* by minimization of variance of P I of t across all Monte Carlo paths at time t, conditional on the information set F t. We can also use our recursive formula for the portfolio value to make the dependence on the argument U t exclusive. Now, because variants of this expression is a quadratic function of Ut, this second form makes it clear that with U here with quadratic optimization. And therefore, these can be solved semi-analytically. But before we do that, let's take a look at this equation from the financial perspective. Using two forms of this equation, we can interpret it in two related ways. The first form of this equation means that all uncertainty in the portfolio value pi t is due to uncertainty of the bank cash account B t. Therefore, an optimal hedge should minimize the cost of hedge capital at each time step t, that will be proportional to this uncertainty. Now, the second equation shows how this can be done by using the coercive relation for pi t, and choosing an optimal stock holding Ut according to this equation. Now we can compute the optimal hedge by setting the derivative of this equation to zero. And this gives us the formula shown here in equation ten. As we said before, we have to compute this relation by going backwards in time starting from time T minus one, then T minus two and so on all the way to time zero. The next and a bit harder question is how to compute this expression. It involves one-step expectations of quantity set time T plus one, conditional on information or at a time. Now, how they can be computed depends on whether we deal with a continuous or discrete state space. If the state space is discrete, then such one state conditional expectations are simply finite sums involving transition probabilities of MGP model. But on the other hand, if we work in a continuous state setting, these conditional expectations can be calculated with Monte Carlo by using expansion in basis functions. We will discuss how we can do it later. But for now, we'll just remember for what comes that Ft will stand for cross-sectional information set at time t. Now, let's consider how we can compute the option price in this framework. First we define a mean option price Ct as a time t expected value of the hedge portfolio pi t. Now, we can use our recursive relation for the portfolio value pi t, and get the second for all these relation. And finally, we can replace the portfolio value pi sub t plus one in this expression by its expectation at the time T plus one. This is because the storm stands here under expectation at time t. So, when we replace it by its future expectation at 90 plus one, we use what is called the Tower law of conditional expectations. We then obtain what is shown in the third line of this equation. And finally, in the last line, we use again the definition of the mean price, so that at the end we have a recurser formula for the mean price itself. So, so far so good however, this is not all yet what we need for option pricing. The thing is that the mean option price C at t corresponds only to the mean of the hedge portfolio, which corresponds to the mean cash amount the seller should put in the bank when she sells the option. But what about risk? Clearly, there is risk that the expected value of cash amount be zero will not be sufficient to adequately hedge adoption in any given scenario. Therefore, the option sellers should charge a premium for the option, and in addition to the mean option price. Now, one possible way to specify such risk premium is shown in this equation. We simply add here discounted sum of all future advances of the hedge portfolio, multiplied by a risk-aversion parameter lambda. Clearly, the smaller the future variance of the replication portfolio, the smaller the risk premium that the seller should charge. But the absolute amount of this premium was controlled by the risk-aversion parameter lambda. This is the expression that we will be working with going forward. Now, the problem of the option seller is to minimize this expression by optimally hedging the option, because she needs to stay competitive when selling the auction. So, our problem is minimization. But we can also formulate that there is a maximization problem if we flip the sign of the whole expression as shown here. We will use this formulation in our next lesson. So, for now I just ask you to take a mental note of this expression. And on this point we are ready to move to our next topic.