In the last lesson,

we derived an algorithmic solution to the problem of

optimal hedging and pricing in our MGP option pricing model.

To remind you this equations,

they are given again here.

So, the backward recursion algorithm says that we have to

run two equations shown here backwards in time starting from

time T minus one and all the way back to

the current time t. But as we already know it is on several occasions,

these relations involve different conditional expectations.

So, the question will be how we should compute this conditional expectations.

Now, I would like to remind you that here we assume a Monte Carlo setting

where conditioning informational set at time t that we called earlier,

f_t is given by a set of all Monte Carlo parts up to time t. So,

with this definition of conditional expectations,

all is left to learn is how to compute them.

Let's take a look first at how

such expectations could be calculated in a discrete state setting.

We have mentioned in the last lesson that we could discretize if we

wanted our MGP model using a Markov Chain approximation to be black Sholes model.

In this setting, we would have a finite set Xn of

different admissible values of the state variable Xt where n would run between one and m,

and m would be the number of states in our discrete state setting.

We would then have some values Qn at this these nodes.

These values can also be thought of as discrete

valued function of a discrete valued argument Xt.

Now, we can use an index P notation shown

here to write it as a discrete valued function of X.

We simply take a sum of all Qn's multiplied by the value of

the kronecker symbol of X and Xn which is equal to

one when X is equal to Xn and equals zero otherwise.

This formula simply produces an identity for

each possible value of facts that can appear as an argument of Qx.

But the advantage of using such formula is that it's now valid for any input X

similar to vector veiled expressions in

linear algebra that are valid for all elements of a vector.

We can now replace the delta symbol in this sum by a bit more suggestive

notation phi n of X which splits the two arguments of the delta symbol.

And so phi n of X is computed the same way as the delta symbol but now,

we can interpret it as what is called one-hot encoding of feature X.

How does this work?

Let's take some fixed value of n and consider the function phi n of X for these n. Now,

for a given input X,

this function will be equal zero unless X coincides with the node value Xn.

Functions with such one-hot encoding can be called one-hot basis functions,

and the whole sum for Qx can now be interpreted as an expansion in these basis functions.

You may wonder of what's the point of looking at

such expansion given then it's extremely sparse.

In fact, only one value in the whole sum is no zero here.

Well, this is certainly true but the main point of writing things this way

is that it can now be generalized to a continuous-state formulation.

All we need to do for a continuous-state case which is our reassumed setting here is to

replace delta peak like basis functions that we had

in the discrete state case by the smoothed-out versions.

Here you can see a set of 12 basis functions that we will be using going forward.

This is not the only choice for continuous space formulation,

but is a very convenient one and will serve our needs.

So, we will stick to this one going forward.

These basis functions are called B-splines.

Let's talk about bit on how these B-splines are constructed.

B-splines are very useful for problems solving interpolation,

when we want to interpret sound function between node points X0 to

Xm by a continuous and smooth spline function of order n. With B-splines,

this is done as follows.

First, we add additional node points X_-n to

X_ -1 to the left of X nodes.

And notes X_M+1 to

X_ M+n to the right of point X_M.

Next, we define a set of B-splines B_i and n of X recursively.

To this sense, first we take n equal to zero and set B_i of

n of X equal one if X is in the interval between Xi and Xi plus one,

and set it to zero otherwise.

And then we define B_in for n larger than zero by the recursive formula shown here.

This formula applies for X in the interval Xi to X_i plus n plus one.

Outside of this intervals B-spline B_in is zero.

As you can see from this formula,

if we take n equal to three,

then B_in are non-negative cubic polynomials.

These B-splines are called cubic B-splines,

and we will use them going forward.

So, B-splines are very useful because they are non-negative,

they integrate to one and are only none-zero on

intervals X_i to X_i+n+1.

Therefore, they form a good basis for non-negative quantities.

If all co-efficients are non-negative,

the whole expression will be non-negative

as the basis functions themselves are non-negative.

So, B-splines so far are very good choice of basis functions,

but this is not the only choice.

Other specifications have been also considered into the future.

For example, we could use a full year cosine basis or wavelength basis.

A harder question though is how to pick a set of

basis functions when we have not just one but many stocks.

We'll be dealing with

these more complex settings later on when we consider multi-asset portfolios.

But for now, we will continue with our single stock portfolio for

an auction on a single underlying as it will keep us busy for the time being.