Crates.io | arima |
lib.rs | arima |
version | 0.3.0 |
source | src |
created_at | 2019-10-19 14:53:22.313107 |
updated_at | 2023-11-22 15:06:20.330513 |
description | ARIMA time series modeling for Rust. |
homepage | https://github.com/krfricke/arima |
repository | https://github.com/krfricke/arima |
max_upload_size | |
id | 173978 |
size | 85,589 |
Rust crate for ARIMA model coefficient estimation and simulation.
extern crate rand;
use rand::prelude::*;
use rand_distr::{Distribution, Normal};
use arima::{estimate, sim};
fn main() {
// initialize RNG with seed
let mut rng: StdRng = SeedableRng::from_seed([100; 32]);
// our noise should be normally distributed
let normal = Normal::new(10.0, 2.0).unwrap();
// simulate time series
let ts = sim::arima_sim(
1000, // number of samples
Some(&[0.7, 0.2]), // AR parameters
Some(&[0.4]), // MA parameters
0, // difference parameter
&|mut rng| { normal.sample(&mut rng) }, // noise fn
&mut rng // RNG
).unwrap();
// estimate AR parameters
let coef = estimate::fit(&ts, 2, 0, 1).unwrap();
println!("Estimated parameters: {:?}", coef);
// Estimated parameters: [14.904840907703845, 0.7524268545022731, 0.14075584488434256, 0.35966423499627603]
}
This crate is licensed under the Apache-2.0 license.