Simulation of stochastic processes.
Continuous-time processes are simulated exactly on a regular grid of n steps over [0, T]
and return { t, x } where t holds the n + 1 grid times and x the path (or an array of
paths when paths is given).
- Source:
Methods
(static) brownianBridge(optionsopt) → {Object}
Brownian bridge from a at time 0 to b at time T.
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Object
(static) brownianMotion(optionsopt) → {Object}
Brownian motion (Wiener process) with drift: dX = mu dt + sigma dW.
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Object
(static) geometricBrownianMotion(optionsopt) → {Object}
Geometric Brownian motion dS = mu S dt + sigma S dW, simulated exactly: S_t = S_0 exp((mu - sigma²/2) t + sigma W_t). The Black–Scholes stock price model.
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Object
(static) inhomogeneousPoissonProcess(intensity, maxRate, Topt) → {Array.<number>}
Arrival times of an inhomogeneous Poisson process with intensity intensity(t) bounded by
maxRate on [0, T], by Lewis–Shedler thinning.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
intensity |
function | Rate function. |
||
maxRate |
number | Upper bound of the intensity on [0, T]. |
||
T |
number |
<optional> |
1 | Time horizon. |
- Source:
Returns:
Sorted arrival times.
- Type
- Array.<number>
(static) markovChain(transition, steps, startopt) → {Array.<number>}
Simulates a discrete-time Markov chain.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
transition |
Array.<Array.<number>> | Row-stochastic transition matrix. |
||
steps |
number | Number of transitions. |
||
start |
number | Array.<number> |
<optional> |
0 | Initial state, or an initial distribution. |
- Source:
Returns:
The visited states (steps + 1 values).
- Type
- Array.<number>
Example
const P = [[0.9, 0.1], [0.5, 0.5]]
markovChain(P, 10, 0) // 11 states starting at 0
(static) ornsteinUhlenbeck(optionsopt) → {Object}
Ornstein–Uhlenbeck process dX = theta (mu - X) dt + sigma dW, simulated with its exact Gaussian transition (no discretisation error). Mean reverting (Vasicek model).
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Object
(static) poissonCountingProcess(rate, optionsopt) → {Object}
Number of events of a compound-free Poisson process at the grid times: N(t) on [0, T].
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rate |
number | |||||||||||||||||
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Object
(static) poissonProcess(rate, Topt) → {Array.<number>}
Arrival times of a homogeneous Poisson process with the given rate on [0, T].
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
rate |
number | Events per unit time (>= 0). |
||
T |
number |
<optional> |
1 | Time horizon. |
- Source:
Returns:
Sorted arrival times.
- Type
- Array.<number>
(static) randomWalk(steps, optionsopt) → {Array.<number>|Array.<Array.<number>>}
Simple random walk: steps of +stepSize with probability p and -stepSize otherwise.
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
steps |
number | Number of steps. |
||||||||||||||||||||||||||
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
Positions (steps + 1 values per path).
- Type
- Array.<number> | Array.<Array.<number>>
Example
randomWalk(100) // 101 positions starting at 0
randomWalk(10, { p: 0.6, start: 5 })
(static) resample(data, sizeopt) → {Array}
Returns a bootstrap resample (sampling with replacement) of the data.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Array | |||
size |
number |
<optional> |
data.length |
- Source:
Returns:
- Type
- Array