# How to scale Histogram counts with the value of bin center?

I am analyzing some variates from a steeply falling power-law distribution (approximately with a power index -4) using

Histogram[data, Automatic, "PDF"]


While the option ScalingFunctions->{"Log", "Log"} helps a lot in keeping the results in perspective, I cannot really see small deviations from the power law since the dominant trend in the log-log view will be a linear function with approximate slope -4. The usual trick in such studies is to scale the resulting pdf by dividing it with the approximate trend, i.e. for the bin entries I want something like

ScalingFunctions->{"Log", Function[{count, center}, Log[center^4 count]]}


instead of only Function[x, Log[x]] which I get with the "Log" option. Unfortunately Histogram seems to call this function with only one argument which is the corresponding bin count (or pdf value in my case), unlike e.g. Plot which calls RegionFunction with all the coordinates and similarly other plotting functions in Mathematica.

Is there a way to convince Mathematica to call the scaling functions not only with the bin value but also with the bin center or location of bin edges?

There is nice 3-rd argument in Histogram

data = RandomReal[1.0, 1000000]^(-1/3);

Histogram[data, 100, #2/(-Subtract @@@ #)/ Total[#2] (Mean /@ #)^4 &,
ScalingFunctions -> {"Log", "Log"}]


Pure #2/(-Subtract @@@ #)/Total[#2] & is equivalent to "PDF".

Results are better with log-scaled bins

Histogram[data, {"Log", 20}, #2/(-Subtract @@@ #)/Total[#2] (Mean /@ #)^4 &,
ScalingFunctions -> {"Log", "Log"}]


P.S. Why I chose RandomReal[1.0, 1000000]^(-1/3) for power-law distribution with a power index -4?

See:

PDF@TransformedDistribution[x^(-1/3), x \[Distributed] UniformDistribution[]]


• Great, that's it! But is berried really deep down in the documentation... Sep 26, 2013 at 18:08
• @DarkoVeberic A lot of interesting things buried in the Details&Options section :) Note that I correct one mistake and update the answer. Sep 26, 2013 at 18:13
• Can you guess which fh function is equivalent to the "PDF" option? Sep 26, 2013 at 18:18
• Ah, great, you've answered it while I was typing the question... Sep 26, 2013 at 18:19