Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.histogramdd

Contents

jax.numpy.histogramdd#

jax.numpy.histogramdd(sample,bins=10,range=None,weights=None,density=None)[source]#

Compute an N-dimensional histogram.

JAX implementation ofnumpy.histogramdd().

Parameters:
  • sample (ArrayLike) – input array of shape(N,D) representingN points inD dimensions.

  • bins (ArrayLike |list[ArrayLike]) – Specify the number of bins in each dimension of the histogram.(default: 10). May also be a length-D sequence of integers or arraysof bin edges.

  • range (Sequence[None |Array |Sequence[ArrayLike]]|None) – Length-D sequence of pairs specifying the range for each dimension.If not specified, the range is inferred from the data.

  • weights (ArrayLike |None) – An optional shape(N,) array specifying the weights of thedata points.Should be the same shape assample. If not specified, eachdata point is weighted equally.

  • density (bool |None) – If True, return the normalized histogram in units of countsper unit volume. If False (default) return the (weighted) counts per bin.

Returns:

A tuple of arrays(histogram,bin_edges), wherehistogram containsthe aggregated data, andbin_edges specifies the boundaries of the bins.

Return type:

tuple[Array,list[Array]]

See also

Examples

A histogram over 100 points in three dimensions

>>>key=jax.random.key(42)>>>a=jax.random.normal(key,(100,3))>>>counts,bin_edges=jnp.histogramdd(a,bins=6,...range=[(-3,3),(-3,3),(-3,3)])>>>counts.shape(6, 6, 6)>>>bin_edges[Array([-3., -2., -1.,  0.,  1.,  2.,  3.], dtype=float32), Array([-3., -2., -1.,  0.,  1.,  2.,  3.], dtype=float32), Array([-3., -2., -1.,  0.,  1.,  2.,  3.], dtype=float32)]

Usingdensity=True returns a normalized histogram:

>>>density,bin_edges=jnp.histogramdd(a,density=True)>>>bin_widths=map(jnp.diff,bin_edges)>>>dx,dy,dz=jnp.meshgrid(*bin_widths,indexing='ij')>>>normed=jnp.sum(density*dx*dy*dz)>>>jnp.allclose(normed,1.0)Array(True, dtype=bool)
Contents

[8]ページ先頭

©2009-2025 Movatter.jp