My apologies; I had modified the appearance to try to make it more clear what I was attempting. I've fixed it now and the code runs as written.

Yes, you are correct about the intermediate piddles (the ones of which I am finding the median) being different lengths. I was thinking perhaps there's some way to expand into extra dimensions, where each dimension would contain the values in a given $b range, and then take medover the entire array to condense it into the form of $d. Is this possible?

Like this, only without having to manually type all of the $mask(..) .= 1 lines:

pdl> $e = $a(,,*3)->copy pdl> p $e [ [ [ 0 6 18 7 19 3 10 2 12 4 8 9 1 15 11 11 19 17 0 9] ] [ [ 0 6 18 7 19 3 10 2 12 4 8 9 1 15 11 11 19 17 0 9] ] [ [ 0 6 18 7 19 3 10 2 12 4 8 9 1 15 11 11 19 17 0 9] ] ] pdl> $mask = $e->zeroes pdl> $mask(,,0)->where(($b>0)*($b<=5)) .= 1 pdl> $mask(,,1)->where(($b>5)*($b<=10)) .= 1 pdl> $mask(,,2)->where(($b>10)*($b<=15)) .= 1 pdl> p $mask [ [ [0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0] ] [ [0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0] ] [ [0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1] ] ] pdl> $mask = $mask->setbadif($mask==0) pdl> p $mask [ [ [BAD 1 1 1 1 1 BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD + BAD BAD BAD] ] [ [BAD BAD BAD BAD BAD BAD 1 1 1 1 1 BAD BAD BAD BAD BAD BAD + BAD BAD BAD] ] [ [BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD 1 1 1 1 1 1 + 1 1 1] ] ] pdl> $f = $e*$mask pdl> p $f [ [ [BAD 6 18 7 19 3 BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD + BAD BAD BAD] ] [ [BAD BAD BAD BAD BAD BAD 10 2 12 4 8 BAD BAD BAD BAD BAD BAD + BAD BAD BAD] ] [ [BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD 9 1 15 11 11 19 + 17 0 9] ] ] pdl> $g = $f->medover pdl> p $g [ [ 7] [ 8] [11] ]

Thank you very much for your help!


In reply to Re^2: Grouping one piddle based on ranges of another by astroman
in thread Grouping one piddle based on ranges of another by astroman

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.