in reply to Re: Seeking a fast sum_of_ranks_between function (1e6 x 1e6 in 1/5th sec.)
in thread Seeking a fast sum_of_ranks_between function
Many thanks, BrowserUk!
Unless I'm misunderstanding your code, it seems to me that the case $aRef->[$a] == $bRef->[$b] is handled wrong. Consider the case (as in the example) $aRef=[1..5]; $bRef=[3, 3.14, 4, 4];. When the loop restarts at $rank==6, $a==3, $b==2, $aRef[$a]==4, $bRef[$b]==4, it adds 6.5 to $aSum and $bSum and increments $a and $b and double-increments $rank. Then the next run-through is at $rank==8, $a==4, $b==3, $aRef[$a]==5, $bRef[$b]==4, and it then adds 8 to $bSum. So, all in all, it adds 6.5 to $aSum and 6.5 and 8 to $bSum; but it should be adding 7 to $aSum and twice 7 to $bSum.
(And that makes a big difference to me, because my data is likely to have a lot of "ties".) But thank you, again.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Seeking a fast sum_of_ranks_between function (1e6 x 1e6 in 1/5th sec.)
by BrowserUk (Patriarch) on Oct 14, 2015 at 14:52 UTC | |
by msh210 (Monk) on Oct 14, 2015 at 15:33 UTC | |
by toolic (Bishop) on Oct 14, 2015 at 15:45 UTC | |
by msh210 (Monk) on Oct 14, 2015 at 15:56 UTC | |
by BrowserUk (Patriarch) on Oct 14, 2015 at 16:19 UTC |