pub struct LineCountHistogram {
pub buckets: Vec<u32>,
pub probabilities: Vec<f64>,
pub n: usize,
}Expand description
Bucket histogram for counts such as lines-per-JE, fan-out, and active lifetime.
Fields§
§buckets: Vec<u32>§probabilities: Vec<f64>§n: usizeImplementations§
Source§impl LineCountHistogram
impl LineCountHistogram
Sourcepub fn build(values: &[u32], buckets: &[u32]) -> (Self, usize)
pub fn build(values: &[u32], buckets: &[u32]) -> (Self, usize)
Build a histogram on the given inclusive-lower-bound bucket grid.
The bucket grid must be sorted ascending. Values >= buckets.last()
fall into the last bucket. Values < buckets[0] are dropped (count
returned for diagnostic use).
Sourcepub fn pool(&self, other: &Self) -> Option<Self>
pub fn pool(&self, other: &Self) -> Option<Self>
Sum bucket counts of self and other (same bucket grid) and
renormalise. Returns None if grids mismatch.
Sourcepub fn median_bucket(&self) -> u32
pub fn median_bucket(&self) -> u32
Median bucket — the smallest buckets[i] whose cumulative probability >= 0.5.
Sourcepub fn sample_bucket<R: Rng>(&self, rng: &mut R) -> u32
pub fn sample_bucket<R: Rng>(&self, rng: &mut R) -> u32
Sample a count from the histogram. Picks a bucket weighted by
probability mass, then samples uniformly within the bucket (between
buckets[i] inclusive and buckets[i+1] exclusive — for the last
bucket, returns buckets[i]).
Trait Implementations§
Source§impl Clone for LineCountHistogram
impl Clone for LineCountHistogram
Source§fn clone(&self) -> LineCountHistogram
fn clone(&self) -> LineCountHistogram
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 moreSource§impl Debug for LineCountHistogram
impl Debug for LineCountHistogram
Source§impl Default for LineCountHistogram
impl Default for LineCountHistogram
Source§fn default() -> LineCountHistogram
fn default() -> LineCountHistogram
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for LineCountHistogram
impl<'de> Deserialize<'de> for LineCountHistogram
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for LineCountHistogram
impl PartialEq for LineCountHistogram
Source§fn eq(&self, other: &LineCountHistogram) -> bool
fn eq(&self, other: &LineCountHistogram) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for LineCountHistogram
impl Serialize for LineCountHistogram
impl StructuralPartialEq for LineCountHistogram
Auto Trait Implementations§
impl Freeze for LineCountHistogram
impl RefUnwindSafe for LineCountHistogram
impl Send for LineCountHistogram
impl Sync for LineCountHistogram
impl Unpin for LineCountHistogram
impl UnsafeUnpin for LineCountHistogram
impl UnwindSafe for LineCountHistogram
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
impl<T> Scalar for T
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.