Random Process#

AR Processes#

class ARProcess(mean, autoreg, noise_sd)[source]#

Bases: RandomVariable

Object to represent an AR(p) process in Numpyro

sample(duration, inits=None, name='arprocess', **kwargs)[source]#

Sample from the AR process

Parameters:
  • duration (int) – Length of the sequence.

  • inits (ArrayLike, optional) – Initial points, if None, then these are sampled. Defaults to None.

  • name (str, optional) – Name of the parameter passed to numpyro.sample. Defaults to “arprocess”.

  • **kwargs (dict, optional) – Additional keyword arguments passed through to internal sample() calls, should there be any.

Returns:

With a single array of shape (duration,).

Return type:

tuple

static validate()[source]#

Validates inputted parameters, implementation pending.

First Difference (AR)#

class FirstDifferenceARProcess(autoreg, noise_sd)[source]#

Bases: RandomVariable

Class for a stochastic process with an AR(1) process on the first differences (i.e. the rate of change).

sample(duration, init_val=None, init_rate_of_change=None, name='trend_rw', **kwargs)[source]#

Sample from the process

Parameters:
  • duration (int) – Passed to ARProcess.sample().s

  • init_val (ArrayLike, optional) – Starting point of the AR process, by default None.

  • init_rate_of_change (ArrayLike, optional) – Passed to ARProcess.sample, by default None.

  • name (str, optional) – Passed to ARProcess.sample(), by default “trend_rw”

  • **kwargs (dict, optional) – Additional keyword arguments passed through to internal sample() calls, should there be any.

Returns:

With a single array of shape (duration,).

Return type:

tuple

static validate()[source]#

Validates inputted parameters, implementation pending.

Reproduction Number Random Walk#

class RtRandomWalkProcess(Rt0_dist, Rt_rw_dist, Rt_transform=None)[source]#

Bases: RandomVariable

Rt Randomwalk Process

Notes

The process is defined as follows:

\[\begin{split}Rt(0) &\sim \text{Rt0_dist} \\ Rt(t) &\sim \text{Rt_transform}(\text{Rt_transformed_rw}(t))\end{split}\]
sample(n_timepoints, **kwargs)[source]#

Generate samples from the process

Parameters:
  • n_timepoints (int) – Number of timepoints to sample.

  • **kwargs (dict, optional) – Additional keyword arguments passed through to internal sample() calls, should there be any.

Returns:

With a single array of shape (n_timepoints,).

Return type:

tuple

static validate(Rt0_dist, Rt_transform, Rt_rw_dist)[source]#

Validates Rt0_dist, Rt_transform, and Rt_rw_dist.

Parameters:
  • Rt0_dist (dist.Distribution, optional) – Initial distribution of Rt, expected dist.Distribution

  • Rt_transform (numpyro.distributions.transforms.Transform) – Transformation applied to the sampled Rt0.

  • Rt_rw_dist (any) – Randomwalk process, expected dist.Distribution.

Return type:

None

Raises:

AssertionError – If Rt0_dist or Rt_rw_dist are not dist.Distribution or if Rt_transform is not numpyro.distributions.transforms.Transform.

Simple Random Walk#

class SimpleRandomWalkProcess(error_distribution)[source]#

Bases: RandomVariable

Class for a Markovian random walk with an a arbitrary step distribution

sample(n_timepoints, name='randomwalk', init=None, **kwargs)[source]#

Samples from the randomwalk

Parameters:
  • n_timepoints (int) – Length of the walk.

  • name (str, optional) – Passed to numpyro.sample, by default “randomwalk”

  • init (float, optional) – Initial point of the walk, by default None

  • **kwargs (dict, optional) – Additional keyword arguments passed through to internal sample() calls, should there be any.

Returns:

With a single array of shape (n_timepoints,).

Return type:

tuple

static validate()[source]#

Validates inputted parameters, implementation pending.