xhistogram

Defined in xtensor/xhistogram.hpp

enum xt::histogram_algorithm

Defines different algorithms to be used in “histogram_bin_edges”.

Values:

automatic
linspace
logspace
uniform
template<class R = double, class E1, class E2, class E3>
auto xt::histogram(E1 &&data, E2 &&bin_edges, E3 &&weights, bool density = false)

Compute the histogram of a set of data.

Return

An one-dimensional xarray<double>, length: bin_edges.size()-1.

Parameters
  • data: The data.

  • bin_edges: The bin-edges.

  • weights: Weight factors corresponding to each data-point.

  • density: If true the resulting integral is normalized to 1. [default: false]

template<class E1, class E2, xtl::check_concept<is_xexpression<std::decay_t<E2>>> = 0>
auto xt::bincount(E1 &&data, E2 &&weights, std::size_t minlength = 0)

Count number of occurrences of each value in array of non-negative ints.

The number of bins (of size 1) is one larger than the largest value in x. If minlength is specified, there will be at least this number of bins in the output array (though it will be longer if necessary, depending on the contents of x). Each bin gives the number of occurrences of its index value in x. If weights is specified the input array is weighted by it, i.e. if a value n is found at position i, out[n] += weight[i] instead of out[n] += 1.

Return

1D container with the bincount

Parameters
  • data: the 1D container with integers to count into bins

  • weights: a 1D container with the same number of elements as data

  • minlength: The minlength

template<class E1, class E2, class E3>
auto xt::histogram_bin_edges(E1 &&data, E2 &&weights, E3 left, E3 right, std::size_t bins = 10, histogram_algorithm mode = histogram_algorithm::automatic)

Compute the bin-edges of a histogram of a set of data using different algorithms.

Return

An one-dimensional xarray<double>, length: bins+1.

Parameters
  • data: The data.

  • weights: Weight factors corresponding to each data-point.

  • left: The lower-most edge.

  • right: The upper-most edge.

  • bins: The number of bins. [default: 10]

  • mode: The type of algorithm to use. [default: “auto”]

Further overloads

template<class E1, class E2>
auto xt::histogram(E1 &&data, E2 &&bin_edges, bool density = false)

Compute the histogram of a set of data.

Return

An one-dimensional xarray<double>, length: bin_edges.size()-1.

Parameters
  • data: The data.

  • bin_edges: The bin-edges.

  • density: If true the resulting integral is normalized to 1. [default: false]

template<class E1>
auto xt::histogram(E1 &&data, std::size_t bins = 10, bool density = false)

Compute the histogram of a set of data.

Return

An one-dimensional xarray<double>, length: bin_edges.size()-1.

Parameters
  • data: The data.

  • bins: The number of bins. [default: 10]

  • density: If true the resulting integral is normalized to 1. [default: false]

template<class E1, class E2>
auto xt::histogram(E1 &&data, std::size_t bins, E2 &&weights, bool density = false)

Compute the histogram of a set of data.

Return

An one-dimensional xarray<double>, length: bin_edges.size()-1.

Parameters
  • data: The data.

  • bins: The number of bins.

  • weights: Weight factors corresponding to each data-point.

  • density: If true the resulting integral is normalized to 1. [default: false]

template<class E1, class E2>
auto xt::histogram_bin_edges(E1 &&data, E2 left, E2 right, std::size_t bins = 10, histogram_algorithm mode = histogram_algorithm::automatic)

Compute the bin-edges of a histogram of a set of data using different algorithms.

Return

An one-dimensional xarray<double>, length: bins+1.

Parameters
  • data: The data.

  • left: The lower-most edge.

  • right: The upper-most edge.

  • bins: The number of bins. [default: 10]

  • mode: The type of algorithm to use. [default: “auto”]

template<class E1, class E2>
auto xt::histogram_bin_edges(E1 &&data, E2 &&weights, std::size_t bins = 10, histogram_algorithm mode = histogram_algorithm::automatic)

Compute the bin-edges of a histogram of a set of data using different algorithms.

Return

An one-dimensional xarray<double>, length: bins+1.

Parameters
  • data: The data.

  • weights: Weight factors corresponding to each data-point.

  • bins: The number of bins. [default: 10]

  • mode: The type of algorithm to use. [default: “auto”]

template<class E1>
auto xt::histogram_bin_edges(E1 &&data, std::size_t bins = 10, histogram_algorithm mode = histogram_algorithm::automatic)

Compute the bin-edges of a histogram of a set of data using different algorithms.

Return

An one-dimensional xarray<double>, length: bins+1.

Parameters
  • data: The data.

  • bins: The number of bins. [default: 10]

  • mode: The type of algorithm to use. [default: “auto”]