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,
impl<X, Fx, Pr> Bocpd<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X>, Pr: ConjugatePrior<X, Fx, Posterior = Pr> + Clone, Fx::Stat: Clone,
sourcepub fn new(hazard_lambda: f64, predictive_prior: Pr) -> Self
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 islambda - 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),
);
sourcepub fn reset_with_prior(&mut self, predictive_prior: Pr)
pub fn reset_with_prior(&mut self, predictive_prior: Pr)
Reset the introspector and replace the predictive prior
sourcepub fn collapse_stats(self) -> Self
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,
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]
fn step(&mut self, data: &X) -> &[f64]
Update the model with a new datum and return the distribution of run lengths.
§type PosteriorPredictive = Mixture<Pr>
type PosteriorPredictive = Mixture<Pr>
Type of predictive prior distribution
source§fn reset(&mut self)
fn reset(&mut self)
Reset internal state, new run-lengths will refer to steps after this point.
source§fn pp(&self) -> Self::PosteriorPredictive
fn pp(&self) -> Self::PosteriorPredictive
Generate the posterior predictive distribution
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,
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§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,
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§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,
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,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
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
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.