Struct changepoint::BocpdTruncated
source · pub struct BocpdTruncated<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 with a truncated tail
The truncation takes place after run length probabilites are computed. The truncation point is chosen based on the most recent point from which all successive mass is below the given threshold.
Implementations§
source§impl<X, Fx, Pr> BocpdTruncated<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx, Posterior = Pr> + Clone,
Fx::Stat: Clone,
impl<X, Fx, Pr> BocpdTruncated<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
- The hazard function forP_{gap} = 1/hazard
.predictive_prior
- Prior for the predictive distribution.
Example
use changepoint::BocpdTruncated;
use rv::prelude::*;
let cpd = BocpdTruncated::new(
250.0,
NormalGamma::new_unchecked(0.0, 1.0, 1.0, 1.0),
);
sourcepub fn with_cutoff(self, cutoff_threadhold: f64) -> Self
pub fn with_cutoff(self, cutoff_threadhold: f64) -> Self
Change the cutoff for mass to be discarded on the tail end of run-lengths
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
source§impl<X, Fx, Pr> BocpdTruncated<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx, Posterior = Pr> + Clone,
Fx::Stat: Clone,
impl<X, Fx, Pr> BocpdTruncated<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X>, Pr: ConjugatePrior<X, Fx, Posterior = Pr> + Clone, Fx::Stat: Clone,
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 BocpdTruncated<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 BocpdTruncated<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 BocpdTruncated<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 BocpdTruncated<X, Fx, Pr>where Fx: Rv<X> + HasSuffStat<X> + Clone, Pr: ConjugatePrior<X, Fx> + Clone, Fx::Stat: Clone + Clone,
source§fn clone(&self) -> BocpdTruncated<X, Fx, Pr>
fn clone(&self) -> BocpdTruncated<X, Fx, Pr>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<X, Fx, Pr> RefUnwindSafe for BocpdTruncated<X, Fx, Pr>where Pr: RefUnwindSafe, <Fx as HasSuffStat<X>>::Stat: RefUnwindSafe,
impl<X, Fx, Pr> Send for BocpdTruncated<X, Fx, Pr>where Pr: Send, <Fx as HasSuffStat<X>>::Stat: Send,
impl<X, Fx, Pr> Sync for BocpdTruncated<X, Fx, Pr>where Pr: Sync, <Fx as HasSuffStat<X>>::Stat: Sync,
impl<X, Fx, Pr> Unpin for BocpdTruncated<X, Fx, Pr>where Pr: Unpin, <Fx as HasSuffStat<X>>::Stat: Unpin,
impl<X, Fx, Pr> UnwindSafe for BocpdTruncated<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.