import boost_histogram as bh
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
h = bh.Histogram(bh.axis.Regular(100, -3.5, 3.5))
data = np.concatenate([
np.random.normal(-.75,.3, 1_000_000),
np.random.normal(.75,.3, 750_000),
np.random.normal(-1.5,.2, 200_000),
])
plt.hist(data, bins=100, density=True);
h.fill(data)
Histogram(Regular(100, -3.5, 3.5), storage=Double()) # Sum: 1950000.0
plt.plot(*h.axes.centers, h, '.')
[<matplotlib.lines.Line2D at 0x7fce995fcd90>]
ho = bh.Histogram(bh.axis.Regular(50, 1, 10))
hl = bh.Histogram(bh.axis.Regular(50, 1, 10, transform=bh.axis.transform.log))
data = np.random.normal(5, 1, 1_000_000)
ho.fill(data)
hl.fill(data)
Histogram(Regular(50, 1, 10, transform=log), storage=Double()) # Sum: 999964.0 (1000000.0 with flow)
plt.plot(*ho.axes.centers, ho, '.')
[<matplotlib.lines.Line2D at 0x7fcec872e5e0>]
plt.plot(*hl.axes.centers, hl, '.')
[<matplotlib.lines.Line2D at 0x7fce684151f0>]