nlcpy.histogram2d
- nlcpy.histogram2d(x, y, bins=10, range=None, normed=None, weights=None, density=None)
Computes the bi-dimensional histogram of two data samples.
- Parameters
- xarray_like,shape(N,)
An array containing the x coordinates of the points to be histogrammed.
- yarray_like,shape(N,)
An array containing the y coordinates of the points to be histogrammed.
- binsint or array_like or [int, int] or [array, array], optional
The bin specification:
If int, the number of bins for the two dimensions (nx=ny=bins).
If array_like, the bin edges for the two dimensions (x_edges=y_edges=bins).
If [int, int], the number of bins in each dimension (nx, ny = bins).
If [array, array], the bin edges in each dimension (x_edges, y_edges = bins).
A combination [int, array] or [array, int], where int is the number of bins and array is the bin edges.
- rangearray_like, shape(2,2), optional
The leftmost and rightmost edges of the bins along each dimension (if not specified explicitly in the bins parameters):
[[xmin, xmax], [ymin, ymax]]
. All values outside of this range will be considered outliers and not tallied in the histogram.- normedbool, optional
An alias for the density argument that behaves identically. To avoid confusion with the broken normed argument to
histogram()
, density should be preferred.- weightsarray_like, shape(N,),optional
An array of values
w_i
weighing each sample(x_i, y_i)
. Weights are normalized to 1 if normed is True. If normed is False, the values of the returned histogram are equal to the sum of the weights belonging to the samples falling into each bin.- densitybool, optional
If False, the default, returns the number of samples in each bin. If True, returns the probability density function at the bin,
bin_count / sample_count / bin_area.
- Returns
- Hndarray,shape(nx, ny)
The bi-dimensional histogram of samples x and y. Values in x are histogrammed along the first dimension and values in y are histogrammed along the second dimension.
- xedgesndarray, shape(nx+1,)
The bin edges along the first dimension.
- yedgesndarray, shape(ny+1,)
The bin edges along the second dimension.
See also
histogram
Computes the histogram of a set of data.
histogramdd
Computes the multidimensional histogram of some data.
Note
When normed is True, then the returned histogram is the sample density, defined such that the sum over bins of the product
bin_value * bin_area
is 1.Please note that the histogram does not follow the Cartesian convention where x values are on the abscissa and y values on the ordinate axis. Rather, x is histogrammed along the first dimension of the array (vertical), and y along the second dimension of the array (horizontal). This ensures compatibility with
histogramdd()
.Restriction
This function is the wrapper function to utilize
numpy.histogram2d()
. Calculations during this function perform on only Vector Host(Linux/x86).Examples
>>> import nlcpy as vp >>> vp.random.seed(42) >>> z = vp.random.randn(2,50) >>> H, xedges,yedges = vp.histogram2d(z[0],z[1], bins=5) >>> H.shape, xedges[0].size, yedges[0].size ((5, 5), 1, 1)