# Log-scale histogram bug

Bug introduced in 8.0.4 and persisting through 13.2.0

Not really a question, more a solution to what I call a bug in mathematica v8(.0.0.4). I already sent a bug report to Wolfram.

### Problem

The documentation for the Histogram-function explains the following option.

{"Log",bspec}       apply binning bspec on log-transformed data.


When specifying the bins in the format {xMin, xMax, dx}, these values are not processed corretly which leads to insatisfying results.

In detail, the lower and upper bounds are transformed to the logarithmic scale using the natural logarithm. From there on, the bin widths are determined using dx and these bin coordinates are transformed back using the common logarithm. One would expect that the routine uses either the natural or the common logarithm for both operations, but not a mixture of the two.

### Example

Imagine, that data is a list of real values.

(* binning settings *)
binMin = 0.01;
binMax = 100;
binWidthLog = 1;
Histogram[data, {"Log", {binMin, binMax, binWidthLog}}]


The minimum and maximum x values clearly don't follow the wanted behaviour. Using custom bin limits, this result can be reproduced as follows with a mixture of common and natural logarithms.

bins = {10^Range[Log[E, binMin], Log[E, binMax], binWidthLog]};
Histogram[data, {"Log", bins}]


• Might I suggest splitting off the "Solution" portion into an honest-to-goodness answer? After all, answering your own questions is kosher here... Nov 14, 2012 at 13:26
• should the question be tagged as "bug"? Nov 14, 2012 at 22:10

### Solution

The fix is obvious, just use one of the two logarithms consistently for the custom bins.

bins = {10^Range[Log[10, binMin], Log[10, binMax], binWidthLog]};
Histogram[data, {"Log", bins}]


I took me quite some time to figure this out so I thought i might be useful to post this here.