ConditionalVarianceProcess¶
- class samplepaths.timeseries.ConditionalVarianceProcess(*, omega, rng=None)[source]¶
Bases:
BaseSequenceProcessBase class of the time series models with a changing variance.
A series of values with a zero mean whose variance depends on the past,
\[X_t = \sigma_t z_t, \quad z_t \sim N(0, 1)\]where the variance \(\sigma_t^2\) is a function of the previous values and of their variances. Calm and agitated periods alternate, as in the returns of financial assets.
A subclass defines that function. A realization starts from the stationary state of the model: the variances before the first value are at their long-run level, and the values before it are drawn at that level.
After a call to
sample()orsample_paths(), the attributevolatilityholds the standard deviations \(\sigma_t\) of the values.- Parameters:
- property volatility: ndarray[tuple[Any, ...], dtype[float64]]¶
Standard deviations \(\sigma_t\) of the most recent realization.
An array of the shape of the result of
sample()orsample_paths(), whichever was called last.- Raises:
RuntimeError – if no realization has been generated yet
- sample(n)[source]¶
Generate a realization.
- Parameters:
n (int) – the number of increments to generate
- Returns:
the realization. Processes with integer values, such as the state of a Markov chain, return an array of integers.
- Return type:
NDArray[float64]
- property rng: Generator¶
Random number generator used by the process.
This is the generator passed at instantiation, or the package default
samplepaths.random.generatorwhen none was given.
- sample_paths(n, paths, workers=1)[source]¶
Generate several independent realizations at once.
The realizations have the distribution of those of
sample(). Many processes generate them together, which is much faster than callingsample()repeatedly. For a given seed, the values differ from those of repeated calls tosample(), because the random numbers are drawn in a different order.With
workersgreater than one, the realizations are generated on that many threads, each with its own generator derived from the generator of the process. The result is reproducible for a given seed and number of workers, and differs between numbers of workers. Processes which generate their realizations one after the other ignoreworkers.