stochasticWeakRandomVariables

namespace stochasticWeakRV

Helpers that convert the underlying Gaussian Wiener increments into the discrete random variables used by the weak-order stochastic Runge-Kutta methods (DRI1, DRI1NM, W2Ito1, …).

Using these transforms (rather than storing the discrete variables directly) means the integrators can be driven either by a random Gaussian generator in production or by a prescribed Gaussian generator in tests, and in both cases the resulting discrete variables match the reference implementation exactly.

Warning

Stochastic integration is in beta.

Functions

inline double threePoint(double dW, double h)

Three-point distributed random variable.

Given a Gaussian increment dW (~ N(0,h)) and the step h, returns a variable taking values in \(\{-\sqrt{3h},\,0,\,+\sqrt{3h}\}\) with probabilities \(\{1/6,\,2/3,\,1/6\}\). The scaled increment dW/sqrt(h) is thresholded against the 1/6 quantile.

inline double twoPoint(double dZ, double scale)

Two-point distributed random variable.

Given a Gaussian increment dZ and a scale s, returns \(+s\) if dZ > 0 else \(-s\). Uses a strictly-positive sign convention: a strictly positive increment maps to +s and zero/negative maps to -s.

Variables

double NORMAL_ONESIX_QUANTILE = -0.9674215661017014

The (negative) 1/6 quantile of the standard normal distribution, used as the threshold for the three-point transform.