Histogram
Python package: neptune-scale
Represents a histogram with explicit bin edges. To specify the data distribution across bins, use either counts or densities.
Use the histogram as a value in the dictionary passed to log_histograms()
.
Parameters
Name | Type | Description |
---|---|---|
bin_edges | One of:
| The bin edges of the histogram. The maximum number of edges is 513. Note that n bins have n+1 bin edges, so the length of the bin_edges argument must be one more than the length of the array that specifies the counts or densities. |
counts | One of:
| Number of data points that fall into each bin, as a 1D array. |
densities | One of:
| Probability density function values for each bin, as a 1D array. |
Examples
Define histogram using data-point counts per bin
from neptune_scale.types import Histogram
neptune_histogram = Histogram(
bin_edges=[0, 1, 40, 89, 1000],
counts=[5, 82, 44, 1],
)
Define histogram using densities
from neptune_scale.types import Histogram
neptune_histogram = Histogram(
bin_edges=[0, 1, 2, 3, 4],
densities=[0.25, 0.25, 0.25, 0.25],
)
Define histograms using NumPy:
import numpy as np
a = np.arange(5)
Counts
counts, bin_edges = np.histogram(a, density=False)
neptune_histogram = Histogram(bin_edges=bin_edges, counts=counts)
Densities
densities, bin_edges = np.histogram(a, density=True)
neptune_histogram = Histogram(bin_edges=bin_edges, densities=densities)