Skip to main content

SlidingWindow

Struct SlidingWindow 

Source
pub struct SlidingWindow<const N: usize> { /* private fields */ }
Expand description

リングバッファベースのスライディングウィンドウ。

最新N個の観測値を保持し、ウィンドウ全体の統計量を提供。

Implementations§

Source§

impl<const N: usize> SlidingWindow<N>

Source

pub const fn new() -> Self

新しいスライディングウィンドウを作成。

Source

pub fn push(&mut self, value: f64)

値を追加。バッファが満杯の場合、最古の値を上書き。

§Panics

N == 0 の場合 (幅 0 のウィンドウは保持できない) 回復可能な入力の誤りでは なく型引数の前提違反なので Result にせず panic する SlidingWindow::<0>::new() 自体は成功し、最初の push で panic する 契約は tests/panic_contract.rs が pin する

Source

pub fn mean(&self) -> f64

平均値。

Source

pub const fn sum(&self) -> f64

合計値。

Source

pub const fn len(&self) -> usize

有効な要素数。

Source

pub const fn is_empty(&self) -> bool

空かどうか。

Source

pub fn min(&self) -> f64

最小値(全走査)。

Source

pub fn max(&self) -> f64

最大値(全走査)。

Source

pub fn variance(&self) -> f64

分散(母集団分散)。

Source

pub fn std_dev(&self) -> f64

標準偏差。

Source

pub const fn clear(&mut self)

ウィンドウをクリア。

Trait Implementations§

Source§

impl<const N: usize> Default for SlidingWindow<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for SlidingWindow<N>
where [f64; N]: Freeze,

§

impl<const N: usize> RefUnwindSafe for SlidingWindow<N>
where [f64; N]: RefUnwindSafe,

§

impl<const N: usize> Send for SlidingWindow<N>
where [f64; N]: Send,

§

impl<const N: usize> Sync for SlidingWindow<N>
where [f64; N]: Sync,

§

impl<const N: usize> Unpin for SlidingWindow<N>
where [f64; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for SlidingWindow<N>
where [f64; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for SlidingWindow<N>
where [f64; N]: UnwindSafe,

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