Skip to main content

Stl

Struct Stl 

Source
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

Source

pub fn new(period: usize) -> Self

STL for a series with this period, with statsmodels’ defaults.

Source

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.

Source

pub fn trend(self, span: usize) -> Self

Span of the trend smoother: odd, at least 3, above the period.

Source

pub fn low_pass(self, span: usize) -> Self

Span of the low-pass smoother: odd, at least 3, above the period.

Source

pub fn seasonal_degree(self, degree: usize) -> Self

Degree (0 or 1) of the seasonal Loess.

Source

pub fn trend_degree(self, degree: usize) -> Self

Degree (0 or 1) of the trend Loess.

Source

pub fn low_pass_degree(self, degree: usize) -> Self

Degree (0 or 1) of the low-pass Loess.

Source

pub fn robust(self, robust: bool) -> Self

Down-weight outliers with the outer loop.

Source

pub fn inner_iterations(self, n: usize) -> Self

Passes of the inner loop (default 5, or 2 when robust). At least 1.

Source

pub fn outer_iterations(self, n: usize) -> Self

Passes of the outer loop (default 0, or 15 when robust).

Source

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).

Source

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.

Source

pub fn decompose(&self, data: &[f64]) -> Result<StlResult, StlError>

Decompose data.

§Errors

StlError when an option is outside its domain, a span is even, there are fewer than two full cycles, or a value is not finite.

Trait Implementations§

Source§

impl Clone for Stl

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Stl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Stl

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Stl

Auto Trait Implementations§

§

impl Freeze for Stl

§

impl RefUnwindSafe for Stl

§

impl Send for Stl

§

impl Sync for Stl

§

impl Unpin for Stl

§

impl UnsafeUnpin for Stl

§

impl UnwindSafe for Stl

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.