pub struct BinarySegmentation {
pub max_changepoints: usize,
pub threshold: f64,
pub min_size: usize,
pub cost_fn: CostFunction,
}Expand description
Binary Segmentation for change point detection.
Greedy algorithm that recursively splits segments at points of maximum change statistic. Time complexity: O(n log n) average, O(n^2) worst case.
§Algorithm
- Compute test statistic for all candidate split points across the full series.
- If the maximum statistic exceeds the threshold, accept the split point.
- Recursively apply to each resulting sub-segment.
- Stop when no segment can be split or max_changepoints is reached.
Fields§
§max_changepoints: usizeMaximum number of change points to detect
threshold: f64Threshold for accepting a change point
min_size: usizeMinimum segment size
cost_fn: CostFunctionCost function
Implementations§
Source§impl BinarySegmentation
impl BinarySegmentation
Sourcepub fn new(max_changepoints: usize, threshold: f64, min_size: usize) -> Self
pub fn new(max_changepoints: usize, threshold: f64, min_size: usize) -> Self
Create a new binary segmentation detector.
Sourcepub fn with_cost(
max_changepoints: usize,
threshold: f64,
min_size: usize,
cost_fn: CostFunction,
) -> Self
pub fn with_cost( max_changepoints: usize, threshold: f64, min_size: usize, cost_fn: CostFunction, ) -> Self
Create with a specific cost function.
Sourcepub fn detect(&self, data: &ArrayView1<'_, f64>) -> Result<ChangePointResult>
pub fn detect(&self, data: &ArrayView1<'_, f64>) -> Result<ChangePointResult>
Detect change points in the data.
Trait Implementations§
Source§impl Clone for BinarySegmentation
impl Clone for BinarySegmentation
Source§fn clone(&self) -> BinarySegmentation
fn clone(&self) -> BinarySegmentation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 Freeze for BinarySegmentation
impl RefUnwindSafe for BinarySegmentation
impl Send for BinarySegmentation
impl Sync for BinarySegmentation
impl Unpin for BinarySegmentation
impl UnsafeUnpin for BinarySegmentation
impl UnwindSafe for BinarySegmentation
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§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 moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.