I didn't investigate what's wrong with OP's code and how to use Math::GSL for the task, but

I would have expected either PDL::Basic's hist or PDL::NDBin to accommodate user-provided ranges, in line with your requirement, but it seems neither of them do.

I think you are wrong here, see Variable-width bins

pdl> p$data = pdl qw/ 1 3 25 1 5 1 3 1 2 2 3 3 3 25 1 1 5 2 4500 1 1 1 + 1 5 5 8 000 1 1 5 500 1 1 1 5 2 1 1 1000 1000 1000 1000 5000 1 25 60 +00 500 25 25 9000 1 1 5 1000 6000 25 10 5 5 5 5 1000 9540 1000 5 1 5 +500 2500 2 5 5 5/ [1 3 25 1 5 1 3 1 2 2 3 3 3 25 1 1 5 2 4500 1 1 1 1 5 5 8000 1 1 5 500 + 1 1 1 5 2 1 1 1000 1000 1000 1000 5000 1 25 6000 500 25 25 9000 1 1 +5 1000 6000 25 10 5 5 5 5 1000 9540 1000 5 1 5 500 2500 2 5 5 5] pdl> $binner = PDL::NDBin->new(axes=>[[x => grid => 10 ** sequence 6]] +) pdl> $binner->feed(x => $data) pdl> $binner->process pdl> p $binner->output->{histogram} [47 7 3 15 0] pdl>

In reply to Re^2: How does Math::GSL accept data? by Anonymous Monk
in thread How does Math::GSL accept data? by hda

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.