David Fokkema <dfokkema@...1511...> writes:
I fixed the bug, I think. At least it's working on my system and I think
it is not invasive. Comments please? I'll send it upstream otherwise...
Does this handle the case where the user has specified bins of
different widths? It looks like you are only using the width of the
first bin:
+ if align == 'center':
+ hw = .5*(bins[1]-bins[0])
+ nbins = [x-hw for x in bins]
+ else:
+ nbins = bins
At least, I've always thought that unequal bins are allowed, but from
the following it seems that the probability density support also makes
an incompatible assumption:
···
if normed:
- db = bins[1]-bins[0]
+ db = nbins[1]-nbins[0]
return 1/(len(y)*db)*n, bins
--
Jouni K. Sepp�nen
http://www.iki.fi/jks
David Fokkema <dfokkema@...1511...> writes:
> I fixed the bug, I think. At least it's working on my system and I think
> it is not invasive. Comments please? I'll send it upstream otherwise...
Does this handle the case where the user has specified bins of
different widths? It looks like you are only using the width of the
first bin:
> + if align == 'center':
> + hw = .5*(bins[1]-bins[0])
> + nbins = [x-hw for x in bins]
> + else:
> + nbins = bins
I am only using the first width, indeed. If different widths are allowed
(and why not?) some more coding has to be done. On the other hand, I use
align = 'center' because I have a detector which samples timing
information at 20 ns intervals. So, when binning timing information, I
only have 0, 20 ns, 40 ns, 60 ns and so forth. Being able to specify
those values as the center of my bin instead of calculating edges myself
(-10, 10, 30, 50, etc.) is very useful. I can't think of an application
where you have bins of different widths and you want to center the
values... Furthermore, when plotting the histogram, the function
calculates the width of the bars only for the first bin and uses that
for all bars. So I think this function is highly unstable when you use
variable sized bins. Matplotlib.mlab.hist only calculates the histogram
and can only use variable sized bins when you want a simple histogram.
Maybe add something to this effect in the docstring?
At least, I've always thought that unequal bins are allowed, but from
the following it seems that the probability density support also makes
an incompatible assumption:
> if normed:
> - db = bins[1]-bins[0]
> + db = nbins[1]-nbins[0]
> return 1/(len(y)*db)*n, bins
It does...
David
···
On Tue, 2007-04-10 at 16:13 +0300, Jouni K. Seppänen wrote: