Quick actions

cmd+k|ctrl+k

Navigation

Languages

1 Histogram Done

Snippet info

Language

Python

Visibility

public

Author

johan.van.breda

Created

2019-03-13T10:46:41Z

Updated

2019-03-13T11:31:16Z

import numpy as np

data = np.random.randint(low=1,high=10, size=100)

print('data = ' + str(data))

# get the histogram of the data, number of elements with value 1,2,...,10
dist = np.histogram(data,bins=[1,2,3,4,5,6,7,8,9])
print('dist = ' + str(dist))

# get the  number of elements in the histogram, should be 100
N = np.sum(d for d in dist[0])
print('N = ' + str(N))
INFO