r"""Returns a sample paths from the process using the Milstein method. For an Ito process, ``` dX = a(t, X_t) dt + b(t, X_t) dW_t ``` given drift `a`, volatility `b` and derivative of volatility `b'`, the Milstein method generates a sequence {Y_n} approximating X ``` Y_{n+1} =
(
*,
dim: int,
drift_fn: Callable[..., types.RealTensor],
volatility_fn: Callable[..., types.RealTensor],
times: types.RealTensor,
time_step: Optional[types.RealTensor] = None,
num_time_steps: Optional[types.IntTensor] = None,
num_samples: types.IntTensor = 1,
initial_state: Optional[types.RealTensor] = None,
grad_volatility_fn: Optional[Callable[..., List[types.RealTensor]]] = None,
random_type: Optional[random.RandomType] = None,
seed: Optional[types.IntTensor] = None,
swap_memory: bool = True,
skip: types.IntTensor = 0,
precompute_normal_draws: bool = True,
watch_params: Optional[List[types.RealTensor]] = None,
stratonovich_order: int = 5,
dtype: Optional[tf.DType] = None,
name: Optional[str] = None)
| 33 | |
| 34 | |
| 35 | def sample( |
| 36 | *, |
| 37 | dim: int, |
| 38 | drift_fn: Callable[..., types.RealTensor], |
| 39 | volatility_fn: Callable[..., types.RealTensor], |
| 40 | times: types.RealTensor, |
| 41 | time_step: Optional[types.RealTensor] = None, |
| 42 | num_time_steps: Optional[types.IntTensor] = None, |
| 43 | num_samples: types.IntTensor = 1, |
| 44 | initial_state: Optional[types.RealTensor] = None, |
| 45 | grad_volatility_fn: Optional[Callable[..., List[types.RealTensor]]] = None, |
| 46 | random_type: Optional[random.RandomType] = None, |
| 47 | seed: Optional[types.IntTensor] = None, |
| 48 | swap_memory: bool = True, |
| 49 | skip: types.IntTensor = 0, |
| 50 | precompute_normal_draws: bool = True, |
| 51 | watch_params: Optional[List[types.RealTensor]] = None, |
| 52 | stratonovich_order: int = 5, |
| 53 | dtype: Optional[tf.DType] = None, |
| 54 | name: Optional[str] = None) -> types.RealTensor: |
| 55 | r"""Returns a sample paths from the process using the Milstein method. |
| 56 | |
| 57 | For an Ito process, |
| 58 | |
| 59 | ``` |
| 60 | dX = a(t, X_t) dt + b(t, X_t) dW_t |
| 61 | ``` |
| 62 | given drift `a`, volatility `b` and derivative of volatility `b'`, the |
| 63 | Milstein method generates a |
| 64 | sequence {Y_n} approximating X |
| 65 | |
| 66 | ``` |
| 67 | Y_{n+1} = Y_n + a(t_n, Y_n) dt + b(t_n, Y_n) dW_n + \frac{1}{2} b(t_n, Y_n) |
| 68 | b'(t_n, Y_n) ((dW_n)^2 - dt) |
| 69 | ``` |
| 70 | where `dt = t_{n+1} - t_n`, `dW_n = (N(0, t_{n+1}) - N(0, t_n))` and `N` is a |
| 71 | sample from the Normal distribution. |
| 72 | |
| 73 | In higher dimensions, when `a(t, X_t)` is a d-dimensional vector valued |
| 74 | function and `W_t` is a d-dimensional Wiener process, we have for the kth |
| 75 | element of the expansion: |
| 76 | |
| 77 | ``` |
| 78 | Y_{n+1}[k] = Y_n[k] + a(t_n, Y_n)[k] dt + \sum_{j=1}^d b(t_n, Y_n)[k, j] |
| 79 | dW_n[j] + \sum_{j_1=1}^d \sum_{j_2=1}^d L_{j_1} b(t_n, Y_n)[k, j_2] I(j_1, |
| 80 | j_2) |
| 81 | ``` |
| 82 | where `L_{j} = \sum_{i=1}^d b(t_n, Y_n)[i, j] \frac{\partial}{\partial x^i}` |
| 83 | is an operator and `I(j_1, j_2) = \int_{t_n}^{t_{n+1}} \int_{t_n}^{s_1} |
| 84 | dW_{s_2}[j_1] dW_{s_1}[j_2]` is a multiple Ito integral. |
| 85 | |
| 86 | |
| 87 | See [1] and [2] for details. |
| 88 | |
| 89 | #### References |
| 90 | [1]: Wikipedia. Milstein method: |
| 91 | https://en.wikipedia.org/wiki/Milstein_method |
| 92 | [2]: Peter E. Kloeden, Eckhard Platen. Numerical Solution of Stochastic |
nothing calls this directly
no test coverage detected