```java.lang.Object Market.Basket
```
Direct Known Subclasses:

extends java.lang.Object

Interface and default methods for all multi assets markets (deterministic or stochastic volatility, deterministic or stochastic rates).

Generally works with discounted prices S^B(t)=S(t)/B(t), where S is the vector of assets and B the riskfree bond. This eliminates interest rates from direct consideration.

PATH COMPUTATION: the basic procedure is to continue a path which has already been realized until time t from this time t to the horizon (branching at time t).

Here we are simulating future scenarios conditioned on all information available at time t (the realized path on [0,t]). This is what is needed for the computation of conditional expectations conditioning on information available at time t. The computation of entire paths is then merely a continuation from time t=0.

Time is measured in discrete units (the time step dt). Thus integer time t corresponds to continuous time t*dt.

A single time step t -> t+1 is driven by a standard normal vector Z using the Cholesky root of the covariation matrix of the returns R_i=log(S_i(t+dt)/S_i(t)). In the present case of deterministic volatility and drifts the time step replicates the stochastic dynamics exactly, that is, without approximation.

 Constructor Summary ```Basket(int T, double dt, double[] S_0, double[] q)```           Constructor, call from concrete subclass.

 Method Summary ` double` ```covarianceOfReturns(double a, double b, int i, int j)```           The covariance Cov(R_i,R_j) of the asset returns R_i=log(S_i(b)/S_i(a)) over the time interval [a,b]. ` ColtMatrix` `covarianceOfReturnsMatrix(int t)`           The covariance matrix Cov(R_i,R_j) of the returns R_i=log(S_i(t+1)/S_i(t)) over the time step t -> t+1. ` double` ```dividendReductionFactor(int i, int t)```           Reduces the price of the i-th asset by future dividends. ` double` ```forwardPrice(int i, int t)```           Forward price of the i-th asset at horizon T. ` double[]` `get_B()`           Reference to the array B[ ] containing the riskfree bond. ` int` `get_dim()`           Dimension, number of assets. ` double` `get_dt()`           Size of time step. ` double[]` `get_q()`           Constant dividend yield. ` double[]` `get_S_0()`           Asset price S(0) at time t=0. ` ColtVector[]` `get_S()`           Reference to the asset price path array. ` int` `get_T()`           Number of time steps to horizon. ` boolean` `get_volatilityIsDeterministic()`           True if the volatility of the asset is deterministic, false otherwise. ` ColtVector` `get_Z()`           The standard normal Z-vector driving the time step t -> t+1. ` void` `newPath(int whichProbability)`           New path of riskfree bond and discounted asset. ` void` ```newPathBranch(int whichProbability, int t)```           Continues a path of the riskfree bond and discounted asset from time t to the horizon (branching at time t). ` int` ```newPathSegment(int whichProbability, int t, Trigger trg)```           Continues a path of the riskfree bond and the discounted asset prices which exists up to time t from this time t to the next time s>t at which the Trigger trg is triggered or s=T, whichever comes first, and returns this time s. ` double` ```S(int i, int t)```           Discounted asset prices. ` void` `simulationInit(int t)`           Sets up a path simulation (t=0) or a simulation of branches of an existing path (t>0, conditional expectations). ` void` ```stepToHorizonSimulationInit(int whichProbability, int t)```           Sets up a path simulation reaching the horizon T in one step from the current time t. `abstract  void` ```timeStep(int whichProbability, int t)```           Time step of riskfree bond and discounted asset prices from discrete time t to time t+1. ` void` `timeStepToHorizon(int t)`           Single time step of riskfree bond and discounted asset prices from discrete time t to the horizon T, skipping intermediate times if possible. ` ColtMatrix` `volatilityMatrix(int t)`           The Cholesky root of the covariance matrix of the returns over the time step t -> t+1.

 Methods inherited from class java.lang.Object `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Constructor Detail

```public Basket(int T,
double dt,
double[] S_0,
double[] q)```

Constructor, call from concrete subclass.

Parameters:
`T` - Number of time steps to horizon.
`dt` - Size of time step.
`S_0` - Asset price vector S(0).
`q` - Vector of dividend yields.
 Method Detail

### get_dim

`public int get_dim()`

Dimension, number of assets.

### get_T

`public int get_T()`

Number of time steps to horizon.

### get_dt

`public double get_dt()`

Size of time step.

### get_S_0

`public double[] get_S_0()`

Asset price S(0) at time t=0.

### get_q

`public double[] get_q()`

Constant dividend yield.

### get_volatilityIsDeterministic

`public boolean get_volatilityIsDeterministic()`

True if the volatility of the asset is deterministic, false otherwise.

### get_B

`public double[] get_B()`

Reference to the array B[ ] containing the riskfree bond.

### get_S

`public ColtVector[] get_S()`

Reference to the asset price path array. get_S()[t] is the vector of discounted asset prices at time t.

### get_Z

`public ColtVector get_Z()`

The standard normal Z-vector driving the time step t -> t+1.

Polymorphic link to the concrete implementations. The basket dynamics may not define such a vector. In this case calling the method is a fatal flaw and so the default implementation is an error message with program exit. Needless to say this will be overridden in some concrete subclasses.

### S

```public double S(int i,
int t)```

Discounted asset prices.

Parameters:
`i` - asset index.
`t` - current time.

### dividendReductionFactor

```public double dividendReductionFactor(int i,
int t)```

Reduces the price of the i-th asset by future dividends.

Parameters:
`t` - Current time.
`i` - index of asset.

### forwardPrice

```public double forwardPrice(int i,
int t)```

Forward price of the i-th asset at horizon T.

Parameters:
`t` - Current time.
`i` - index of asset.

### covarianceOfReturns

```public double covarianceOfReturns(double a,
double b,
int i,
int j)```

The covariance Cov(R_i,R_j) of the asset returns R_i=log(S_i(b)/S_i(a)) over the time interval [a,b]. Not defined in this generality. Error message, abort. Is overriden in subclasses.

Parameters:
`a` - time begin.
`b` - time stop.
`i` - asset index.
`j` - asset index.

### covarianceOfReturnsMatrix

`public ColtMatrix covarianceOfReturnsMatrix(int t)`

The covariance matrix Cov(R_i,R_j) of the returns R_i=log(S_i(t+1)/S_i(t)) over the time step t -> t+1.

The method is only a polymorphic link to the concrete implementations. The basket dynamics may not define such a matrix. In this case calling the method is a fatal flaw and so the default implementation is an error message with program exit. Needless to say this will be overridden in some concrete subclasses.

### volatilityMatrix

`public ColtMatrix volatilityMatrix(int t)`

The Cholesky root of the covariance matrix of the returns over the time step t -> t+1. This matrix drives the time step of various concrete subclasses.

The method is only a polymorphic link to the concrete implementations. The basket dynamics may not define such a matrix. In this case calling the method is a fatal flaw and so the default implementation is an error message with program exit. Needless to say this will be overridden in some concrete subclasses.

### simulationInit

`public void simulationInit(int t)`

Sets up a path simulation (t=0) or a simulation of branches of an existing path (t>0, conditional expectations). Do all loop (path) independent work here to speed up simulation. Default: nothing to do, polymorphic link to concrete subclasses.

Parameters:
`t` - Time of branching.

### stepToHorizonSimulationInit

```public void stepToHorizonSimulationInit(int whichProbability,
int t)```

Sets up a path simulation reaching the horizon T in one step from the current time t. Do all loop (path) independent work here to speed up simulation. Default: nothing to do, polymorphic link to concrete subclasses.

Parameters:
`whichProbability` - Probability for simulation (market/risk neutral).
`t` - Time of branching.

### timeStep

```public abstract void timeStep(int whichProbability,
int t)```

Time step of riskfree bond and discounted asset prices from discrete time t to time t+1. In case of nonstochastic interest rates the path of the riskfree bond is handled by the constuctor.

Parameters:
`whichProbability` - Probability for simulation (market/risk neutral).
`t` - Current time.

### timeStepToHorizon

`public void timeStepToHorizon(int t)`

Single time step of riskfree bond and discounted asset prices from discrete time t to the horizon T, skipping intermediate times if possible.

In some models the large time steps t->T can be simulated without loss of accuracy in others predictor corrector simulation is reasonably accurate In each case large time steps imply significant speedup as the asset price path has to be sampled only at the needed times.

Default implementation: steps through all intermediate times by calling `timeStep(int)` in the risk neutral probability. This should be overidden in concrete subclasses by more efficient methods. The probability is chosen by the method `stepToHorizonSimulationInit`.

Parameters:
`t` - Current time.

### newPathBranch

```public void newPathBranch(int whichProbability,
int t)```

Continues a path of the riskfree bond and discounted asset from time t to the horizon (branching at time t).

Default implementation: repeated calls to timeStep. Obviously that has function call overhead. Override this with more efficient implementation if desired.

Parameters:
`whichProbability` - Probability for simulation (market/risk neutral).
`t` - time of branching.

### newPath

`public void newPath(int whichProbability)`

New path of riskfree bond and discounted asset.

Parameters:
`whichProbability` - Probability for simulation (market/risk neutral).

### newPathSegment

```public int newPathSegment(int whichProbability,
int t,
Trigger trg)```

Continues a path of the riskfree bond and the discounted asset prices which exists up to time t from this time t to the next time s>t at which the Trigger trg is triggered or s=T, whichever comes first, and returns this time s.

The Trigger could be a signal triggering a hedge trade or option exercise for example.

Default implementation: repeated calls to timeStep. Obviously that has function call overhead. Override this with more efficient implementation if desired.

Parameters:
`whichProbability` - Probability for simulation (market/risk neutral).
`t` - branching time (time at which new branch starts).
`trg` - Stopping time >= t until which the path is computed.