Struct ndarray_stats::histogram::Bins [−][src]
Bins
is a sorted collection of non-overlapping
1-dimensional intervals.
All intervals are left-inclusive and right-exclusive.
Example:
use ndarray_stats::histogram::{Edges, Bins}; use noisy_float::types::n64; let edges = Edges::from(vec![n64(0.), n64(1.), n64(2.)]); let bins = Bins::new(edges); // first bin assert_eq!( bins.index(0), n64(0.)..n64(1.) // n64(1.) is not included in the bin! ); // second bin assert_eq!( bins.index(1), n64(1.)..n64(2.) );
Implementations
impl<A: Ord> Bins<A>
[src]
pub fn new(edges: Edges<A>) -> Self
[src]
Given a collection of Edges
, it returns the corresponding Bins
instance.
pub fn len(&self) -> usize
[src]
Returns the number of bins.
Example:
use ndarray_stats::histogram::{Edges, Bins}; use noisy_float::types::n64; let edges = Edges::from(vec![n64(0.), n64(1.), n64(2.)]); let bins = Bins::new(edges); assert_eq!( bins.len(), 2 );
pub fn index_of(&self, value: &A) -> Option<usize>
[src]
Given value
, it returns:
Some(i)
, if thei
-th bin inself
containsvalue
;None
, ifvalue
does not belong to any of the bins inself
.
Example:
use ndarray_stats::histogram::{Edges, Bins}; let edges = Edges::from(vec![0, 2, 4, 6]); let bins = Bins::new(edges); let value = 1; assert_eq!( bins.index_of(&1), Some(0) ); assert_eq!( bins.index(bins.index_of(&1).unwrap()), 0..2 );
pub fn range_of(&self, value: &A) -> Option<Range<A>> where
A: Clone,
[src]
A: Clone,
Given value
, it returns:
Some(left_edge..right_edge)
, if there exists a bin inself
such thatleft_edge <= value < right_edge
;None
, otherwise.
Example:
use ndarray_stats::histogram::{Edges, Bins}; let edges = Edges::from(vec![0, 2, 4, 6]); let bins = Bins::new(edges); assert_eq!( bins.range_of(&1), Some(0..2) ); assert_eq!( bins.range_of(&10), None );
pub fn index(&self, index: usize) -> Range<A> where
A: Clone,
[src]
A: Clone,
Get the i
-th bin.
Panics if index
is out of bounds.
Example:
use ndarray_stats::histogram::{Edges, Bins}; let edges = Edges::from(vec![1, 5, 10, 20]); let bins = Bins::new(edges); assert_eq!( bins.index(1), 5..10 );
Trait Implementations
impl<A: Clone + Ord> Clone for Bins<A>
[src]
impl<A: Debug + Ord> Debug for Bins<A>
[src]
impl<A: Eq + Ord> Eq for Bins<A>
[src]
impl<A: PartialEq + Ord> PartialEq<Bins<A>> for Bins<A>
[src]
impl<A: Ord> StructuralEq for Bins<A>
[src]
impl<A: Ord> StructuralPartialEq for Bins<A>
[src]
Auto Trait Implementations
impl<A> RefUnwindSafe for Bins<A> where
A: RefUnwindSafe,
A: RefUnwindSafe,
impl<A> Send for Bins<A> where
A: Send,
A: Send,
impl<A> Sync for Bins<A> where
A: Sync,
A: Sync,
impl<A> Unpin for Bins<A> where
A: Unpin,
A: Unpin,
impl<A> UnwindSafe for Bins<A> where
A: UnwindSafe,
A: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,