pub struct GridBuilder<B: BinsBuildingStrategy> { /* private fields */ }
Expand description

A builder used to create Grid instances for histogram computations.

Examples

Basic usage, creating a Grid with some observations and a given strategy:

use ndarray::Array;
use ndarray_stats::histogram::{strategies::Auto, Bins, Edges, Grid, GridBuilder};

// 1-dimensional observations, as a (n_observations, n_dimension) 2-d matrix
let observations = Array::from_shape_vec(
    (12, 1),
    vec![1, 4, 5, 2, 100, 20, 50, 65, 27, 40, 45, 23],
).unwrap();

// The optimal grid layout is inferred from the data, given a chosen strategy, Auto in this case
let grid = GridBuilder::<Auto<usize>>::from_array(&observations).unwrap().build();
// Equivalently, build a Grid directly
let expected_grid = Grid::from(vec![Bins::new(Edges::from(vec![1, 20, 39, 58, 77, 96, 115]))]);

assert_eq!(grid, expected_grid);

Implementations

Returns a GridBuilder for building a Grid with a given strategy and some observations in a 2-dimensionalarray with shape (n_observations, n_dimension).

Errors

It returns BinsBuildError if it is not possible to build a Grid given the observed data according to the chosen strategy.

Examples

See Trait-level examples for basic usage.

Returns a Grid instance, with building parameters infered in from_array, according to the specified strategy and observations provided.

Examples

See [Trait-level examples] for basic usage.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.