[][src]Function arima::sim::arima_sim

pub fn arima_sim<T: Rng>(
    n: usize,
    ar: Option<&[f64]>,
    ma: Option<&[f64]>,
    d: usize,
    noise_fn: &dyn Fn(&mut T) -> f64,
    rng: &mut T
) -> Result<Vec<f64>, ArimaError>

Simulate an ARIMA model time series

Arguments

  • n - Length of the time series
  • ar - Model parameters for the AR part
  • ma - Model parameters for the MA part
  • d - Model parameter for the differences
  • noise_fn - Function that takes a `Rng' as input and returns noise
  • rng - Reference to a mutable Rng.

Returns

  • Output vector of length n containing the time series data.

Example

use rand::prelude::*;
use rand::distributions::{Normal, Distribution};

let normal = Normal::new(0.0, 2.0);

let x = arima::sim::arima_sim(
    100,
    Some(&[0.9, -0.3, 0.2]),
    Some(&[0.4, 0.2]),
    1,
    &|mut rng| { normal.sample(&mut rng) },
    &mut thread_rng()
).unwrap();