pub struct BicrementalMedianDev<M: CommutativeGroup>where
    M::Set: Ord + Clone,{ /* private fields */ }
Expand description

中央値と偏差の管理。

多重集合 $S$ への要素の追加と削除を行いつつ、中央値と偏差を管理する。 ここで、偏差は中央値との絶対値の総和とする。 $S$ のうち小さい方から $\lceil|S|/2\rceil$ 個取り出したものを $L$、 残りの $\lfloor|S|/2\rfloor$ 個取り出したものを $R$ とする。 中央値を $L$ の最大値として定義し、$a_{\text{med}}$ と書く。 このとき、偏差 $\sigma$ は次のように書ける。 $$ \sigma = \sum_{a\in L} (a_{\text{med}}-a) + \sum_{a\in R} (a-a_{\text{med}}). $$ $\sum_{a\in L} a = \sigma_L$、$\sum_{a\in R} a = \sigma_R$ とすると、 $$ \begin{aligned} \sigma &= \begin{cases} -\sigma_L + \sigma_R, & \text{if } |L| = |R|; \\ -\sigma_L + \sigma_R + a_{\text{med}}, & \text{if } |L| = |R|+1. \\ \end{cases} \end{aligned} $$

Implementations§

source§

impl<M: CommutativeGroup> BicrementalMedianDev<M>where M::Set: Ord + Clone,

source

pub fn new() -> Selfwhere M: Default,

source

pub fn with(cgroup: M) -> Self

source

pub fn insert(&mut self, x: M::Set)

source

pub fn remove(&mut self, x: M::Set) -> bool

source

pub fn median(&self) -> Option<&M::Set>

source

pub fn median_dev(&self) -> M::Set

Trait Implementations§

source§

impl<M: Clone + CommutativeGroup> Clone for BicrementalMedianDev<M>where M::Set: Ord + Clone + Clone,

source§

fn clone(&self) -> BicrementalMedianDev<M>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<M: Debug + CommutativeGroup> Debug for BicrementalMedianDev<M>where M::Set: Ord + Clone + Debug,

source§

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

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

impl<M: PartialEq + CommutativeGroup> PartialEq<BicrementalMedianDev<M>> for BicrementalMedianDev<M>where M::Set: Ord + Clone + PartialEq,

source§

fn eq(&self, other: &BicrementalMedianDev<M>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<M: Eq + CommutativeGroup> Eq for BicrementalMedianDev<M>where M::Set: Ord + Clone + Eq,

source§

impl<M: CommutativeGroup> StructuralEq for BicrementalMedianDev<M>where M::Set: Ord + Clone,

source§

impl<M: CommutativeGroup> StructuralPartialEq for BicrementalMedianDev<M>where M::Set: Ord + Clone,

Auto Trait Implementations§

§

impl<M> RefUnwindSafe for BicrementalMedianDev<M>where M: RefUnwindSafe, <M as Magma>::Set: RefUnwindSafe,

§

impl<M> Send for BicrementalMedianDev<M>where M: Send, <M as Magma>::Set: Send,

§

impl<M> Sync for BicrementalMedianDev<M>where M: Sync, <M as Magma>::Set: Sync,

§

impl<M> Unpin for BicrementalMedianDev<M>where M: Unpin, <M as Magma>::Set: Unpin,

§

impl<M> UnwindSafe for BicrementalMedianDev<M>where M: UnwindSafe, <M as Magma>::Set: UnwindSafe + RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V