pub struct Stl { /* private fields */ }Expand description
STL decomposition with a builder for its options.
§Examples
use u_analytics::decomposition::Stl;
// A rising line plus a cycle of four.
let pattern = [2.0, -1.0, 0.5, -1.5];
let y: Vec<f64> = (0..48).map(|i| 0.3 * i as f64 + pattern[i % 4]).collect();
let r = Stl::new(4).decompose(&y).unwrap();
assert!((r.seasonal[20] - 2.0).abs() < 1e-6);
assert!(r.seasonal_strength > 0.99);Implementations§
Source§impl Stl
impl Stl
Sourcepub fn new(period: usize) -> Self
pub fn new(period: usize) -> Self
STL for a series with this period, with statsmodels’ defaults.
Sourcepub fn seasonal(self, span: usize) -> Self
pub fn seasonal(self, span: usize) -> Self
Span of the seasonal smoother: odd, at least 3. Larger = a seasonal pattern that changes more slowly from cycle to cycle.
Sourcepub fn trend(self, span: usize) -> Self
pub fn trend(self, span: usize) -> Self
Span of the trend smoother: odd, at least 3, above the period.
Sourcepub fn low_pass(self, span: usize) -> Self
pub fn low_pass(self, span: usize) -> Self
Span of the low-pass smoother: odd, at least 3, above the period.
Sourcepub fn seasonal_degree(self, degree: usize) -> Self
pub fn seasonal_degree(self, degree: usize) -> Self
Degree (0 or 1) of the seasonal Loess.
Sourcepub fn trend_degree(self, degree: usize) -> Self
pub fn trend_degree(self, degree: usize) -> Self
Degree (0 or 1) of the trend Loess.
Sourcepub fn low_pass_degree(self, degree: usize) -> Self
pub fn low_pass_degree(self, degree: usize) -> Self
Degree (0 or 1) of the low-pass Loess.
Sourcepub fn inner_iterations(self, n: usize) -> Self
pub fn inner_iterations(self, n: usize) -> Self
Passes of the inner loop (default 5, or 2 when robust). At least 1.
Sourcepub fn outer_iterations(self, n: usize) -> Self
pub fn outer_iterations(self, n: usize) -> Self
Passes of the outer loop (default 0, or 15 when robust).
Sourcepub fn default_trend_span(period: usize, seasonal: usize) -> usize
pub fn default_trend_span(period: usize, seasonal: usize) -> usize
The trend span used when none is given: the smallest odd integer at
least 1.5 · period / (1 − 1.5 / seasonal) (Cleveland et al. 1990,
§3.5; statsmodels’ default).
Sourcepub fn default_low_pass_span(period: usize) -> usize
pub fn default_low_pass_span(period: usize) -> usize
The low-pass span used when none is given: the smallest odd integer above the period.