From ef41836ec5931f394afd7b1319171320608c8452 Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg Date: Fri, 6 Jul 2018 10:52:19 +0200 Subject: [PATCH] Small improvements to Histogram docs --- src/histogram.rs | 2 ++ src/lib.rs | 10 +++++++++- src/traits.rs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/histogram.rs b/src/histogram.rs index f51459e..8fc184a 100644 --- a/src/histogram.rs +++ b/src/histogram.rs @@ -23,7 +23,9 @@ macro_rules! define_histogram { /// A histogram with a number of bins known at compile time. #[derive(Debug, Clone)] pub struct $name { + /// The ranges defining the bins of the histogram. range: [f64; LEN + 1], + /// The bins of the histogram. bin: [u64; LEN], } diff --git a/src/lib.rs b/src/lib.rs index 7b58f86..c8b4e8a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ //! Everything is calculated iteratively in a single pass using constant memory, //! so the sequence of numbers can be an iterator. The used algorithms try to //! avoid numerical instabilities. -//! +//! //! If you want [Serde](https://github.com/serde-rs/serde) support, //! include `"serde"` in your list of features. //! @@ -45,6 +45,7 @@ //! * Quantiles ([`Quantile`]). //! * Minimum ([`Min`]) and maximum ([`Max`]). //! +//! //! ## Estimating several statistics at once //! //! The estimators are designed to have minimal state. The recommended way to @@ -59,6 +60,12 @@ //! only need to include the highest moment in your struct. //! //! +//! ## Calculating histograms +//! +//! The [`define_histogram`] macro can be used to define a histogram struct that +//! uses constant memory. +//! +//! //! [`Mean`]: ./struct.Mean.html //! [`MeanWithError`]: ./type.MeanWithError.html //! [`WeightedMean`]: ./struct.WeightedMean.html @@ -70,6 +77,7 @@ //! [`Min`]: ./struct.Min.html //! [`Max`]: ./struct.Max.html //! [`concatenate`]: ./macro.concatenate.html +//! [`define_histogram`]: ./macro.define_histogram.html #![cfg_attr(feature = "cargo-clippy", allow(float_cmp))] diff --git a/src/traits.rs b/src/traits.rs index 639e04f..fae83bc 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -55,7 +55,7 @@ pub trait Histogram: /// Return an iterator over the bin variances. /// - /// This is more efficient than using `variance()` each bin. + /// This is more efficient than calling `variance()` for each bin. #[inline] fn variances(&self) -> IterVariances<<&Self as IntoIterator>::IntoIter> { let sum: u64 = self.bins().iter().sum();