Re: getting data for Histogram
- To: mathgroup at smc.vnet.net
- Subject: [mg80492] Re: getting data for Histogram
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 23 Aug 2007 01:18:27 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fagthk$8re$1@smc.vnet.net>
Arkadiusz.Majka at gmail.com wrote: > 3 years ago the following problem was given > > "I assume that in the process of creating a Histogram plot, > Mathematica must be calculating a list of BinCounts -- but how can I get at that > list immediately after making and displaying the histogram? " > > Do you know the answer? I am not aware of anything that could pick up the data directly from the internal algorithms used by *Histogram*. However, since version 6.0, one can use *BinCounts* to get the bin count. See http://reference.wolfram.com/mathematica/ref/BinCounts.html?q=BinCounts In[1]:= << Histograms` In[2]:= data = RandomReal[{0, 100}, {50}] Out[2]= {96.1075, 18.0923, 96.2353, 99.5241, 34.5468, 32.116, \ 39.3154, 61.3372, 99.3868, 74.1702, 84.882, 50.3428, 28.8086, 31.934, \ 68.2407, 86.2068, 20.078, 63.0273, 18.6142, 64.4437, 73.6088, \ 94.7681, 6.53301, 78.1354, 36.7259, 77.2206, 7.88085, 63.8245, \ 11.1141, 63.8362, 72.0066, 24.7236, 99.7387, 85.3514, 86.6751, \ 88.128, 32.0117, 84.6678, 16.8106, 30.1619, 3.66506, 1.06579, \ 44.6632, 44.5645, 26.1511, 54.2806, 34.4001, 41.902, 73.1706, \ 81.9539} In[3]:= Histogram[data, HistogramCategories -> 5] [... graphic deleted ...] In[4]:= BinCounts[data, 20] Out[4]= {8, 12, 5, 12, 13} In[5]:= $Version Out[5]= "6.0 for Microsoft Windows (32-bit) (June 19, 2007)" (Note that HistogramCategories specifies the number of intervals whereas the second parameter of BinCounts specifies the width of each interval, i.e. (100 - 0) / 5 == 20 in the above example.) -- Jean-Marc