generate_ar1_series#

causalpy.data.simulate_data.generate_ar1_series(n, phi=0.9, scale=1.0, initial=0.0)[source]#

Generate an AR(1) series x[t] = phi * x[t - 1] + eta[t].

Parameters:
  • n (int) – Length of the series.

  • phi (float) – Autoregressive coefficient. Stationary series need phi in (-1, 1).

  • scale (float) – Standard deviation of the innovation.

  • initial (float) – First value of the series.

Returns:

Series of length n. Uses the global NumPy random stream.

Return type:

np.ndarray

Examples

>>> np.random.seed(42)
>>> series = generate_ar1_series(n=10, phi=0.9, scale=0.5)
>>> len(series)
10