|
[Date Index]
[Thread Index]
[Author Index]
Re: Getting histogram information
- To: mathgroup at smc.vnet.net
- Subject: [mg100714] Re: Getting histogram information
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Thu, 11 Jun 2009 21:42:11 -0400 (EDT)
- References: <h0qoi1$klv$1@smc.vnet.net>
Raul Martinez wrote:
> All,
>
> I have used the Histogram[] function many times. It works well and has
> lots of options but seems to lack transparency.
>
> Specifically, if I don't specify a bin width and let the function
> compute it, I want to know exactly what bin width the function used.
> Obviously, with some additional work I can infer the bin width from
> the resulting histogram. It would be better, however, to know
> precisely the bin width that the function actually used.
>
> I consulted Wolfram support about this and they were helpful,
> providing me with a bit of clever but rather obscure code that returns
> the populated histogram bins. But this still requires additional work
> to infer the bin width. The code provided by Wolfram support is listed
> after the signature.
>
> Can anyone figure out how to get the bin width directly from the
> Histogram[] function?
>
It's not possible. If you need a *simple* approach, and don't want to
use the code you were given, just specify the bin width yourself.
If you look under more information, you'll find a list of methods that
Mathematica can use to automatically find a bin width that produces a
"smooth" histogram. You can look up the methods, and implement them
yourself (some of them are pretty simple). Then you'll have both
automatic bin width calculation *and* and the exact bin width.
Of course the ideal situation would be if Mathematica provided access to
the binning functions it uses for these methods, so we wouldn't have to
implement them ourselves.
So I poked around inside Histogram (in v7) and found the following
binning functions:
Histogram`HistogramBayesianBinning
Histogram`HistogramFreedmanDiaconisBinning
Histogram`HistogramScottBinning
Histogram`HistogramSturgesBinning
Histogram`HistogramWandBinning
At least some of these functions take an argument, which is a function
they use to transform again the bin width they calculate. I don't know
what histogram uses for this transformation function, but we can just
use Identity.
So, here's the simplest way to have both automatic bin width calculation
and know the exact bin width:
Histogram[data, Histogram`HistogramWandBinning[Identity]]
gives the histogram and
Histogram`HistogramWandBinning[Identity][data]
gives the exact bin specification.
(Use Differences to get the bin width)
Prev by Date:
Re: Re: RandomReal gets stuck
Next by Date:
Re: Presentation quick with grid and pasted graphic
Previous by thread:
Re: Getting histogram information
Next by thread:
Creating Matrix from vectors Specific issue
|