pub struct FittedCount {
pub base: usize,
pub diffs: Vec<i128>,
}Expand description
An integer-valued polynomial in the scale, in the finite-difference (binomial) basis:
value(m) = Σ_k diffs[k] · C(m − base, k). Fitted from consecutive window evaluations; the
interpolation certificate is that the difference table vanishes beyond the allowed degree — every
window point past the fitting prefix is an exact verification.
Fields§
§base: usize§diffs: Vec<i128>Implementations§
Source§impl FittedCount
impl FittedCount
Sourcepub fn fit(
base: usize,
values: &[i128],
max_degree: usize,
) -> Option<FittedCount>
pub fn fit( base: usize, values: &[i128], max_degree: usize, ) -> Option<FittedCount>
Fit values observed at consecutive scales base, base+1, …. Returns None (fail-closed)
unless the finite-difference table vanishes above max_degree — which, given
values.len() > max_degree + 1, is exactly the statement that the fitted polynomial
reproduces every extra window point.
Sourcepub fn parity(&self, m: usize) -> bool
pub fn parity(&self, m: usize) -> bool
The parity at any scale, via Lucas: C(a, k) is odd iff k & a == k (every base-2 digit of
k is ≤ the digit of a). No big integers, valid at every m ≥ base.
Sourcepub fn parity_period(&self) -> usize
pub fn parity_period(&self) -> usize
The period of FittedCount::parity in m: C(·, k) mod 2 has period 2^⌈log₂(k+1)⌉, so
the parity’s period is the next power of two above the highest odd-coefficient index.
Trait Implementations§
Source§impl Clone for FittedCount
impl Clone for FittedCount
Source§fn clone(&self) -> FittedCount
fn clone(&self) -> FittedCount
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FittedCount
impl Debug for FittedCount
Source§impl PartialEq for FittedCount
impl PartialEq for FittedCount
Source§fn eq(&self, other: &FittedCount) -> bool
fn eq(&self, other: &FittedCount) -> bool
self and other values to be equal, and is used by ==.