A Monte Carlo pricer turns a normal draw into a terminal stock price, a call payoff and a discounted value. If the interest rate changes, how does the change travel through those steps, given that the rate enters both the growth of the stock and the discount factor? This lesson writes one simulated path as a computational graph, differentiates it in forward and reverse mode, and then asks when the average of these path derivatives is the derivative of the price. The answer is yes for the delta of a call under an integrable bound, and no for a digital option, whose sensitivity lives entirely at the strike.
Key terms
Computational graph
Definition A computational graph of a program is a directed acyclic graph whose nodes are the inputs, the intermediate values and the outputs of the computation, with an edge from to when is computed by an elementary operation that uses . Each edge carries the local partial derivative of that operation, evaluated at the computed values. If every operation is differentiable at those values, the chain rule says that the derivative of an output with respect to an input is the sum, over all directed paths from the input to the output, of the product of the local derivatives along each path. For one simulated terminal value of a stock without dividends in the Black-Scholes model under a pricing measure , fix a realization of the standard normal variable and compute
with inputs , and , and with , and held fixed. The rate reaches the discounted payoff along two paths, one through the exponent and one through the discount factor .
In plain words The graph is the recipe of the computation drawn as a network. It records which quantities feed which, so that every route by which an input affects the result can be found and none is forgotten.
Example Take the constructed inputs , , year, , and . Then , , , and . The path through the exponent contributes the product , and the path through the discount factor contributes . On this path, which ends in the money, the total is
The stock terms cancel, and dropping either route gives a wrong derivative.
Automatic differentiation
Definition Automatic differentiation (AD) evaluates derivatives of a function defined by a program by applying the chain rule to the program’s elementary operations, each of which has a known local derivative. It uses no step size. At an input where every operation is differentiable at its computed arguments and every branch taken stays the same for all nearby inputs, it returns the derivative of the function that the program computes, up to floating-point rounding. In forward mode a seed vector of input tangents is pushed through the graph in the order of computation,
and one sweep returns , the directional derivative of every output, where is the Jacobian of the outputs with respect to the inputs. A sweep costs a small constant multiple of one evaluation, and a full Jacobian with inputs takes forward sweeps. AD differentiates the computation, not the price it approximates. Time discretization, the Monte Carlo sample, exercise decisions and fitted parameters are all part of what is differentiated. If a model parameter is calibrated to market quotes, a sensitivity to a quote needs the dependence of the fit on the quote, obtained either by differentiating through the calibration or by the implicit function theorem applied to its optimality conditions, when these are continuously differentiable and their Jacobian with respect to the parameters is invertible. Holding the fitted parameter fixed answers a different question.
In plain words Forward mode follows a small change of one input through the computation, step by step, and reads off how much every result moves per unit of change. Unlike a finite difference it never actually changes the input, so there is no step to choose and no truncation error. It differentiates exactly what the code computes, approximations included.
Example On the constructed path, seed with . Then , , and because the path ends in the money, while . The product rule at gives
A second sweep seeded with starts from and returns . Two inputs of interest take two forward sweeps.
Reverse-mode adjoint
Definition For a scalar output , the adjoint of a node is , the rate at which changes when changes and the change is passed through every operation that uses . Seeding and visiting the nodes in reverse order of computation,
where the sum runs over all edges leaving . The adjoints of the inputs form the gradient of . One reverse sweep costs a small constant multiple of one evaluation whatever the number of inputs, so it suits a price with many inputs, while forward mode suits few inputs and many outputs. Reverse mode needs the intermediate values of the forward computation, which it stores or recomputes, and checkpointing stores some of them and recomputes the rest to save memory. A node used in several places must add the contributions of all its edges, and overwriting one with another drops part of the chain rule. Iterative solvers and branches need their own treatment, for example by differentiating the converged equations instead of every iteration.
In plain words Reverse mode starts from the price and works backward, asking for each intermediate value how much the price would move per unit change in it. Each node collects a contribution from every place its value is used, so one backward pass gives the sensitivity to every input at once.
Example On the constructed path, sends and . The positive part passes times the in-the-money indicator, so . From come and , and the exponential gives . The exponent sends and a contribution to the rate, and the discount factor adds , so . One sweep returns all three sensitivities, and they agree with the forward sweeps.
Pathwise derivative
Definition Let be a discounted payoff computed from a parameter and random inputs , here the normal draw. The pathwise derivative at is with held fixed, wherever it exists. For the call path with , and ,
measured in currency per currency unit of spot, currency per unit of decimal volatility and currency per unit of decimal rate. On paths with all three are zero, and at the payoff has a kink and no derivative. The pathwise estimator of a price sensitivity is the average of the path derivatives over independent draws. It estimates the right quantity only when the derivative and the expectation can be exchanged, the subject of the next card. Central differences computed with the same draws check a path derivative, while fresh draws for each bumped input would mix a change of path into the difference.
In plain words Keep the random numbers fixed and ask how this one simulated payoff responds to an input. It is the derivative of a known function and needs no new simulation.
Example On the constructed path, , and . To first order, one volatility point, a change of in , moves this path’s payoff by about , and one basis point of rate moves it by about . Central differences with the same and step give , and . With step the volatility difference gives about , off in the fifth significant digit because of its step error.
Interchange of derivative and expectation
Definition Let for in an open interval, with each integrable, and fix in it. Suppose that (i) with probability one, is differentiable at , and (ii) there are and an integrable random variable such that, for each with , the bound holds with probability one. Then is differentiable at and
The proof applies dominated convergence to the difference quotients along any sequence . For the call delta, is Lipschitz with constant , so condition (ii) holds with , and . Condition (i) holds because has a continuous law when and , so the kink has probability zero. Hence
with
For vega and rho similar bounds hold for in a small closed interval, because the exponential of a normal variable times a polynomial in it is integrable, and the averages of the path derivatives are and . In other models a kink of probability zero is not enough by itself, and the integrable bound is what carries the argument. If , the terminal price is deterministic, and the price has no derivative at , where the kink has probability one.
In plain words The average of the path derivatives is the derivative of the price when a small change in the input moves every path payoff by at most a proportional amount whose average is finite. A kink that paths hit with probability zero passes this test, and a jump does not.
Example For the constructed inputs and , so , the vega is and the rho is . A run of four million draws with a fixed seed gives pathwise averages of about , and , with standard errors of about , and , consistent with these values. A single path can be far from the average. For all three path derivatives are zero, while the option’s delta is about .
Discontinuous digital payoff
Definition A cash-or-nothing digital call pays currency unit at if . With fixed, its discounted path payoff is piecewise constant in , so on every path with , that is with probability one, and AD through the indicator returns a zero delta on every path. The price has
so the interchange fails. Condition (ii) of the previous card is what breaks. A bump of spot changes the payoff by on the event that crosses , whose probability is of order , so the difference quotient equals on that event, and no integrable bounds these quotients for all small . The change in price comes from probability mass that moves across the strike, which the path derivative does not see. Methods that handle it under their own assumptions include the likelihood ratio method, which differentiates the lognormal density instead of the payoff and in this model gives
conditioning on part of the randomness to get a smooth conditional expectation, smoothing the indicator at the cost of a bias, and analytic boundary terms. The same failure affects the second derivatives of a call. The pathwise delta jumps at the strike, so differentiating it again path by path returns zero on every path, while the gamma is positive. A valid first-order pathwise derivative does not make the second-order one valid.
In plain words An indicator jumps, so a small bump of spot changes almost no paths and changes those few by a whole unit of payoff. Path derivatives see only the flat parts, and the entire sensitivity of the price sits in the jumps.
Example For a constructed digital with and the other inputs as before, and its delta is about per currency unit of spot. On the path it pays , and the payoff does not change until spot falls to , so every small bump gives a zero difference. A run of four million draws gives a likelihood ratio estimate of about with standard error . For the call with the same inputs the gamma is about , and differentiating the pathwise delta again returns zero.
Check yourself
- On the constructed path, change the draw to . Find the terminal price, the path payoff and the three path derivatives. Does it follow that the delta of the option is zero?
Show the answer
The exponent is , so , below the strike . The payoff is and stays for small changes of , and , so all three path derivatives are zero. The delta of the option is not zero. By the interchange result it is the expectation of the path derivative over all draws,
and under the path ends in the money with probability . A single path derivative is one draw of the pathwise estimator, not the derivative of the price.
- In a hand-written reverse sweep for the constructed path, the line for the discount factor sets instead of adding to it, and it runs after the exponent has set . What rate sensitivity does the code report, and how would a test catch the bug?
Show the answer
The code reports , the discount route alone. With the two lines in the other order it would report , the exponent route alone. The correct adjoint adds both,
A central difference in with the same draw and step gives and exposes the error at once. For many draws, the average of the correct pathwise rho can also be compared with the Black-Scholes rho .
- A desk prices the constructed digital by Monte Carlo and gets its delta by AD through the comparison in the code. What delta does it get, which hypothesis fails, and how can the delta be estimated correctly?
Show the answer
Every path contributes a zero derivative, so the desk gets a delta of , while the true delta is . Condition (i) holds, since the paths miss the strike with probability one, but condition (ii) fails, because the payoff jumps by and no integrable bound controls the difference quotients near the strike. The likelihood ratio estimator averages and gave about with standard error from four million draws. A smoothed payoff, for example one that rises linearly from to as moves across , is Lipschitz, so the interchange applies to it, but it is a different payoff. Its delta has a bias that vanishes as , while the variance of its pathwise estimator grows like . In this model the analytic formula gives the answer directly.