Message Boards Message Boards

Understanding HistogramList result - number of bins

Posted 10 years ago

Dear colleagues, please help me understand this:

In[1]:= data = RandomVariate[NormalDistribution[0, 1], 200];
HistogramList[data, 3]

Out[2]= {{-4, -2, 0, 2, 4}, {5, 84, 109, 2}}

Why there are four and not three bins?

Thank you!

POSTED BY: Tomáš Hruš
2 Replies
Posted 10 years ago

Thank you!

POSTED BY: Tomáš Hruš

Hi,

see this discussion: http://mathematica.stackexchange.com/questions/7724/problems-specifying-number-of-bins-in-histogram

Conclusion: you need to use the undocumented option "Raw".

HistogramList[data, {"Raw", 3}]

this gives the exact number of bins you want. Note that this comes with the usual health warning: it is an undocumented option and you use it at your own risk. The behaviour you see in the standard HistogramList command is apparently actually intended. Also note that the same thing works for the Histogram command.

HistogramList[data, {"Raw", 3}]

gives

enter image description here

Cheers,

M.

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract