pub struct GradientHistogram {
pub buckets: Vec<f32>,
pub counts: Vec<usize>,
pub total_values: usize,
/* private fields */
}Expand description
Bucket-based gradient histogram builder.
The bucket edges are linearly spaced between [min, max]
(inclusive endpoints stored as the first and last element of buckets).
Values outside [min, max] are clamped into the first/last bucket.
Fields§
§buckets: Vec<f32>Bucket edges (length = num_buckets + 1).
counts: Vec<usize>Count per bucket (length = num_buckets).
total_values: usizeTotal number of values added.
Implementations§
Source§impl GradientHistogram
impl GradientHistogram
Sourcepub fn new(num_buckets: usize, min: f32, max: f32) -> Self
pub fn new(num_buckets: usize, min: f32, max: f32) -> Self
Create a new histogram with linearly spaced edges in [min, max].
Panics if num_buckets == 0 or min >= max.
Sourcepub fn add_values(&mut self, vals: &[f32])
pub fn add_values(&mut self, vals: &[f32])
Add multiple values.
Sourcepub fn mean(&self) -> f32
pub fn mean(&self) -> f32
Compute the mean of all inserted values.
Returns 0.0 if no values have been added.
Sourcepub fn std_dev(&self) -> f32
pub fn std_dev(&self) -> f32
Compute the sample standard deviation of all inserted values.
Returns 0.0 if fewer than 2 values have been added.
Sourcepub fn percentile(&self, p: f32) -> f32
pub fn percentile(&self, p: f32) -> f32
Approximate the p-th percentile (0.0–100.0) via bucket interpolation.
Returns the lower bucket edge when counts are insufficient for interpolation.
Sourcepub fn to_ascii_bars(&self) -> String
pub fn to_ascii_bars(&self) -> String
Render a compact horizontal bar chart (one line per bucket).
Trait Implementations§
Source§impl Clone for GradientHistogram
impl Clone for GradientHistogram
Source§fn clone(&self) -> GradientHistogram
fn clone(&self) -> GradientHistogram
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for GradientHistogram
impl RefUnwindSafe for GradientHistogram
impl Send for GradientHistogram
impl Sync for GradientHistogram
impl Unpin for GradientHistogram
impl UnsafeUnpin for GradientHistogram
impl UnwindSafe for GradientHistogram
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
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.