/rust/registry/src/index.crates.io-1949cf8c6b5b557f/ndarray-stats-0.7.0/src/lib.rs
Line | Count | Source |
1 | | //! The [`ndarray-stats`] crate exposes statistical routines for `ArrayRef`, |
2 | | //! the *n*-dimensional array data structure provided by [`ndarray`]. |
3 | | //! |
4 | | //! Currently available routines include: |
5 | | //! - [order statistics] (minimum, maximum, median, quantiles, etc.); |
6 | | //! - [summary statistics] (mean, skewness, kurtosis, central moments, etc.) |
7 | | //! - [partitioning]; |
8 | | //! - [correlation analysis] (covariance, pearson correlation); |
9 | | //! - [measures from information theory] (entropy, KL divergence, etc.); |
10 | | //! - [measures of deviation] (count equal, L1, L2 distances, mean squared err etc.) |
11 | | //! - [histogram computation]. |
12 | | //! |
13 | | //! Please feel free to contribute new functionality! A roadmap can be found [here]. |
14 | | //! |
15 | | //! Our work is inspired by other existing statistical packages such as |
16 | | //! [`NumPy`] (Python) and [`StatsBase.jl`] (Julia) - any contribution bringing us closer to |
17 | | //! feature parity is more than welcome! |
18 | | //! |
19 | | //! [`ndarray-stats`]: https://github.com/rust-ndarray/ndarray-stats/ |
20 | | //! [`ndarray`]: https://github.com/rust-ndarray/ndarray |
21 | | //! [order statistics]: trait.QuantileExt.html |
22 | | //! [partitioning]: trait.Sort1dExt.html |
23 | | //! [summary statistics]: trait.SummaryStatisticsExt.html |
24 | | //! [correlation analysis]: trait.CorrelationExt.html |
25 | | //! [measures of deviation]: trait.DeviationExt.html |
26 | | //! [measures from information theory]: trait.EntropyExt.html |
27 | | //! [histogram computation]: histogram/index.html |
28 | | //! [here]: https://github.com/rust-ndarray/ndarray-stats/issues/1 |
29 | | //! [`NumPy`]: https://docs.scipy.org/doc/numpy-1.14.1/reference/routines.statistics.html |
30 | | //! [`StatsBase.jl`]: https://juliastats.github.io/StatsBase.jl/latest/ |
31 | | |
32 | | pub use crate::correlation::CorrelationExt; |
33 | | pub use crate::deviation::DeviationExt; |
34 | | pub use crate::entropy::EntropyExt; |
35 | | pub use crate::histogram::HistogramExt; |
36 | | pub use crate::maybe_nan::{MaybeNan, MaybeNanExt}; |
37 | | pub use crate::quantile::{interpolate, Quantile1dExt, QuantileExt}; |
38 | | pub use crate::sort::Sort1dExt; |
39 | | pub use crate::summary_statistics::SummaryStatisticsExt; |
40 | | |
41 | | #[cfg(test)] |
42 | | #[macro_use] |
43 | | extern crate approx; |
44 | | |
45 | | #[macro_use] |
46 | | mod multi_input_error_macros { |
47 | | macro_rules! return_err_if_empty { |
48 | | ($arr:expr) => { |
49 | | if $arr.len() == 0 { |
50 | | return Err(MultiInputError::EmptyInput); |
51 | | } |
52 | | }; |
53 | | } |
54 | | macro_rules! return_err_unless_same_shape { |
55 | | ($arr_a:expr, $arr_b:expr) => { |
56 | | use crate::errors::{MultiInputError, ShapeMismatch}; |
57 | | if $arr_a.shape() != $arr_b.shape() { |
58 | | return Err(MultiInputError::ShapeMismatch(ShapeMismatch { |
59 | | first_shape: $arr_a.shape().to_vec(), |
60 | | second_shape: $arr_b.shape().to_vec(), |
61 | | }) |
62 | | .into()); |
63 | | } |
64 | | }; |
65 | | } |
66 | | } |
67 | | |
68 | | #[macro_use] |
69 | | mod private { |
70 | | /// This is a public type in a private module, so it can be included in |
71 | | /// public APIs, but other crates can't access it. |
72 | | pub struct PrivateMarker; |
73 | | |
74 | | /// Defines an associated function for a trait that is impossible for other |
75 | | /// crates to implement. This makes it possible to add new associated |
76 | | /// types/functions/consts/etc. to the trait without breaking changes. |
77 | | macro_rules! private_decl { |
78 | | () => { |
79 | | /// This method makes this trait impossible to implement outside of |
80 | | /// `ndarray-stats` so that we can freely add new methods, etc., to |
81 | | /// this trait without breaking changes. |
82 | | /// |
83 | | /// We don't anticipate any other crates needing to implement this |
84 | | /// trait, but if you do have such a use-case, please let us know. |
85 | | /// |
86 | | /// **Warning** This method is not considered part of the public |
87 | | /// API, and client code should not rely on it being present. It |
88 | | /// may be removed in a non-breaking release. |
89 | | fn __private__(&self, _: crate::private::PrivateMarker); |
90 | | }; |
91 | | } |
92 | | |
93 | | /// Implements the associated function defined by `private_decl!`. |
94 | | macro_rules! private_impl { |
95 | | () => { |
96 | 0 | fn __private__(&self, _: crate::private::PrivateMarker) {}Unexecuted instantiation: <ndarray::ArrayRef<_, ndarray::dimension::dim::Dim<[usize; 2]>> as ndarray_stats::correlation::CorrelationExt<_>>::__private__ Unexecuted instantiation: <ndarray::ArrayRef<_, ndarray::dimension::dim::Dim<[usize; 1]>> as ndarray_stats::sort::Sort1dExt<_>>::__private__ Unexecuted instantiation: <ndarray::ArrayRef<_, _> as ndarray_stats::entropy::EntropyExt<_, _>>::__private__ Unexecuted instantiation: <ndarray::ArrayRef<_, _> as ndarray_stats::quantile::QuantileExt<_, _>>::__private__ Unexecuted instantiation: <ndarray::ArrayRef<_, ndarray::dimension::dim::Dim<[usize; 1]>> as ndarray_stats::quantile::Quantile1dExt<_>>::__private__ Unexecuted instantiation: <ndarray::ArrayRef<_, _> as ndarray_stats::deviation::DeviationExt<_, _>>::__private__ Unexecuted instantiation: <ndarray::ArrayRef<_, _> as ndarray_stats::maybe_nan::MaybeNanExt<_, _>>::__private__ Unexecuted instantiation: <ndarray::ArrayRef<_, _> as ndarray_stats::summary_statistics::SummaryStatisticsExt<_, _>>::__private__ Unexecuted instantiation: <ndarray_stats::quantile::interpolate::Higher as ndarray_stats::quantile::interpolate::Interpolate<_>>::__private__ Unexecuted instantiation: <ndarray_stats::quantile::interpolate::Nearest as ndarray_stats::quantile::interpolate::Interpolate<_>>::__private__ Unexecuted instantiation: <ndarray_stats::quantile::interpolate::Midpoint as ndarray_stats::quantile::interpolate::Interpolate<_>>::__private__ Unexecuted instantiation: <ndarray_stats::quantile::interpolate::Linear as ndarray_stats::quantile::interpolate::Interpolate<_>>::__private__ Unexecuted instantiation: <ndarray_stats::quantile::interpolate::Lower as ndarray_stats::quantile::interpolate::Interpolate<_>>::__private__ Unexecuted instantiation: <ndarray::ArrayRef<_, ndarray::dimension::dim::Dim<[usize; 2]>> as ndarray_stats::histogram::histograms::HistogramExt<_>>::__private__ |
97 | | }; |
98 | | } |
99 | | } |
100 | | |
101 | | mod correlation; |
102 | | mod deviation; |
103 | | mod entropy; |
104 | | pub mod errors; |
105 | | pub mod histogram; |
106 | | mod maybe_nan; |
107 | | mod quantile; |
108 | | mod sort; |
109 | | mod summary_statistics; |