ca5
7/10/2014 - 6:35 AM

numpy sample

numpy sample

>>> import numpy
>>> data = [100, 250, 342, 345, 2, ...]
>>> hist, bin_edges = numpy.histogram(data,numpy.arange(0, 600, 10))
>>> hist
array([     0,      2,      9,      6,      8,      8,     23,     50,
           16,     20,      9,      4,      4,      2,      1,      1,
            2,      0,      0,      4,      1,      1,      1,      0,
            1,      0,      1,      0,      1,      0,      0,      0,
            1,      0,      0,      0,      0,      0,      0,      1,
            0,      0,      0,      0,      0,      1,      1,      0,
            0,      0,      0,      0,      0,      0,      0,      1,
            0,      0,      0])
>>> bin_edges
array([  0,  10,  20,  30,  40,  50,  60,  70,  80,  90, 100, 110, 120,
       130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250,
       260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380,
       390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510,
       520, 530, 540, 550, 560, 570, 580, 590])
>>> hist.sum()
357