# Simple Example¶

Let’s try some basic functionality of boost-histogram:

[1]:

import boost_histogram as bh
import numpy as np

[2]:

vals = np.random.normal(size=(2, 1_000_000))

[3]:

hist = bh.Histogram(
bh.axis.Regular(10, 0, 10, metadata="x", transform=bh.axis.transform.sqrt),
bh.axis.Regular(10, 0, 1, circular=True, metadata="y"),
storage=bh.storage.Int64(),
)
hist

[3]:

Histogram(
Regular(10, 0, 10, metadata='x', transform=sqrt),
Regular(10, 0, 1, circular=True, metadata='y'),
storage=Int64())


This fills the histogram

[4]:

hist.fill(*vals)

[4]:

Histogram(
Regular(10, 0, 10, metadata='x', transform=sqrt),
Regular(10, 0, 1, circular=True, metadata='y'),
storage=Int64()) # Sum: 499682.0 (1000000.0 with flow)


Let’s just take a quick look at the bin contents:

[5]:

print(hist.view())

[[ 3955  3992  3972  3948  3930  3987  4073  3982  3878  4073]
[11519 11675 11560 11528 11612 11575 11476 11643 11573 11603]
[16197 16087 16261 16043 15775 15912 16067 16010 15973 15998]
[12843 12956 12855 12912 12870 12940 12962 12891 12752 13073]
[ 4807  4952  4844  4859  4869  4788  4657  4931  4775  4874]
[  636   618   598   608   633   644   603   635   611   645]
[   14    18    20    13    12    21    10    18    15    22]
[    0     0     0     0     1     0     0     0     0     0]
[    0     0     0     0     0     0     0     0     0     0]
[    0     0     0     0     0     0     0     0     0     0]]