[][src]Struct ndarray_stats::histogram::Histogram

pub struct Histogram<A: Ord> { /* fields omitted */ }

Histogram data structure.

Methods

impl<A: Ord> Histogram<A>[src]

pub fn new(grid: Grid<A>) -> Self[src]

Returns a new instance of Histogram given a Grid.

pub fn add_observation<S>(
    &mut self,
    observation: &ArrayBase<S, Ix1>
) -> Result<(), BinNotFound> where
    S: Data<Elem = A>, 
[src]

Adds a single observation to the histogram.

Panics if dimensions do not match: self.ndim() != observation.len().

Example:

use ndarray::array;
use ndarray_stats::histogram::{Edges, Bins, Histogram, Grid};
use noisy_float::types::n64;

let edges = Edges::from(vec![n64(-1.), n64(0.), n64(1.)]);
let bins = Bins::new(edges);
let square_grid = Grid::from(vec![bins.clone(), bins.clone()]);
let mut histogram = Histogram::new(square_grid);

let observation = array![n64(0.5), n64(0.6)];

histogram.add_observation(&observation)?;

let histogram_matrix = histogram.counts();
let expected = array![
    [0, 0],
    [0, 1],
];
assert_eq!(histogram_matrix, expected.into_dyn());

pub fn ndim(&self) -> usize[src]

Returns the number of dimensions of the space the histogram is covering.

pub fn counts(&self) -> ArrayViewD<usize>[src]

Borrows a view on the histogram counts matrix.

pub fn grid(&self) -> &Grid<A>[src]

Borrows an immutable reference to the histogram grid.

Auto Trait Implementations

impl<A> Send for Histogram<A> where
    A: Send

impl<A> Sync for Histogram<A> where
    A: Sync

impl<A> Unpin for Histogram<A> where
    A: Unpin

impl<A> UnwindSafe for Histogram<A> where
    A: UnwindSafe

impl<A> RefUnwindSafe for Histogram<A> where
    A: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,