#315 hist() truncates fractional $step

closed-fixed
core (120)
5
2013-03-24
2012-11-17
No

If hist() is passed a pdl of integral
datatype and a fractional stepsize,
the step value is converted to an
integer type which gives bad results.

hist($long_pdl,0,5,1) works

hist($long_pdl,0,5,0.5) generates bin
locations with increments of floor($step)

It would seem that hist() should always
return floating point bin locations.

E.g.,

pdl> $xlong = long(0,1,1,2,2,2,4,5,5,6,8,9)

pdl> p $xlong
[0 1 1 2 2 2 4 5 5 6 8 9]

pdl> p $xlong->hist(0,10,1.5)
[0.75 1.75 2.75 3.75 4.75 5.75] [3 3 1 2 1 2]

pdl> p $xlong->float->hist(0,10,1.5)
[0.75 2.25 3.75 5.25 6.75 8.25] [3 3 1 2 1 2]

The example is with PDL-2.4.11_001 but the
problem does not appear to be version or
platform specific from a quick look at the code.

Discussion

  • Chris Marshall

    Chris Marshall - 2013-01-01

    Bug fixed in Git.
    Thanks for reporting the problem!

     
  • Chris Marshall

    Chris Marshall - 2013-01-01
    • assigned_to: nobody --> marshallch
    • status: open --> pending-fixed
     
  • Chris Marshall

    Chris Marshall - 2013-01-01

    The calculation of number of bins and step size
    now correctly handles the case of fractional stepsize.
    This necessitated a change of the default type of
    of the bin center locations to type double pdls.

     
  • Chris Marshall

    Chris Marshall - 2013-03-24
    • status: pending-fixed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks