Struct changepoint::Bocpd

source ·
pub struct Bocpd<X, Fx, Pr>where
    Fx: Rv<X> + HasSuffStat<X>,
    Pr: ConjugatePrior<X, Fx>,
    Fx::Stat: Clone,{ /* private fields */ }
Expand description

Online Bayesian Change Point Detection state container.

Implementations§

source§

impl<X, Fx, Pr> Bocpd<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X>, Pr: ConjugatePrior<X, Fx, Posterior = Pr> + Clone, Fx::Stat: Clone,

source

pub fn new(hazard_lambda: f64, predictive_prior: Pr) -> Self

Create a new Bocpd analyzer

Parameters
  • hazard - 1/ hazard is the probability of the next step being a change-point. Therefore, the larger the value, the lower the prior probability is for the any point to be a change-point. Mean run-length is lambda - 1.
  • predictive_prior - Prior for the predictive distribution. This should match your observed data.
Example
use changepoint::Bocpd;
use rv::prelude::*;

let cpd = Bocpd::new(
    250.0,
    NormalGamma::new_unchecked(0.0, 1.0, 1.0, 1.0),
);
source

pub fn reset_with_prior(&mut self, predictive_prior: Pr)

Reset the introspector and replace the predictive prior

source

pub fn collapse_stats(self) -> Self

Reduce the observed values into a new BOCPD with those observed values integrated into the prior.

Trait Implementations§

source§

impl<X, Fx, Pr> BocpdLike<X> for Bocpd<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X>, Pr: ConjugatePrior<X, Fx, Posterior = Pr> + Clone, Fx::Stat: Clone,

source§

fn step(&mut self, data: &X) -> &[f64]

Update the model with a new datum and return the distribution of run lengths.

§

type Fx = Fx

Type of type of distribution
§

type PosteriorPredictive = Mixture<Pr>

Type of predictive prior distribution
source§

fn reset(&mut self)

Reset internal state, new run-lengths will refer to steps after this point.
source§

fn pp(&self) -> Self::PosteriorPredictive

Generate the posterior predictive distribution
source§

fn preload(&mut self, data: &[X])

Preload a seqeunce into the default suff stat
source§

impl<X: Clone, Fx, Pr> Clone for Bocpd<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X> + Clone, Pr: ConjugatePrior<X, Fx> + Clone, Fx::Stat: Clone + Clone,

source§

fn clone(&self) -> Bocpd<X, Fx, Pr>

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<X: Debug, Fx, Pr> Debug for Bocpd<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X> + Debug, Pr: ConjugatePrior<X, Fx> + Debug, Fx::Stat: Clone + Debug,

source§

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

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

impl<X: PartialEq, Fx, Pr> PartialEq<Bocpd<X, Fx, Pr>> for Bocpd<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X> + PartialEq, Pr: ConjugatePrior<X, Fx> + PartialEq, Fx::Stat: Clone + PartialEq,

source§

fn eq(&self, other: &Bocpd<X, Fx, Pr>) -> 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<X, Fx, Pr> StructuralPartialEq for Bocpd<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X>, Pr: ConjugatePrior<X, Fx>, Fx::Stat: Clone,

Auto Trait Implementations§

§

impl<X, Fx, Pr> RefUnwindSafe for Bocpd<X, Fx, Pr>where Pr: RefUnwindSafe, <Fx as HasSuffStat<X>>::Stat: RefUnwindSafe,

§

impl<X, Fx, Pr> Send for Bocpd<X, Fx, Pr>where Pr: Send, <Fx as HasSuffStat<X>>::Stat: Send,

§

impl<X, Fx, Pr> Sync for Bocpd<X, Fx, Pr>where Pr: Sync, <Fx as HasSuffStat<X>>::Stat: Sync,

§

impl<X, Fx, Pr> Unpin for Bocpd<X, Fx, Pr>where Pr: Unpin, <Fx as HasSuffStat<X>>::Stat: Unpin,

§

impl<X, Fx, Pr> UnwindSafe for Bocpd<X, Fx, Pr>where Pr: UnwindSafe, <Fx as HasSuffStat<X>>::Stat: UnwindSafe,

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> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,

§

impl<T> SendAlias for T

§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,

§

impl<T> SyncAlias for T