[
https://issues.apache.org/jira/browse/MATH-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13736898#comment-13736898
]
Phil Steitz edited comment on MATH-1019 at 8/12/13 2:31 PM:
------------------------------------------------------------
OK, assuming the section link works and what is described there matches what we
have, I agree it is easier. It would be nice to reference the e-book in any
case, as that was the original source. The lecture notes linked in the javadoc
were eventually published as the ebook and removed from the university web
site. At least the relevant section matches my recollection of the nice
description and justification for the shuffle algorithm in the original link.
I see now that there does not actually appear to be a "dead trees version"
after all. apologies for that :) I assumed the pdf was an image of a physical
book published by the University of Aberdeen. Looks like it is only
distributed as an ebook, generally behind a paywall. It can be referenced as
_Algorithms_, by Ian Craw, John Pulham, University of Aberdeen 1999.
was (Author: psteitz):
OK, assuming the section link works and what is described there matches
what we have, I agree it is easier. It would be nice to reference the e-book
in any case, as that was the original source. I see now that there does not
actually appear to be a "dead trees version" after all. apologies for that :)
I assumed the pdf was an image of a physical book published by the University
of Aberdeen. Looks like it is only distributed as an ebook, generally behind a
paywall. It can be referenced as _Algorithms_, by Ian Craw, John Pulham,
University of Aberdeen 1999
> "shuffle" method broken (in class "o.a.c.m.random.RandomDataGenerator")
> -----------------------------------------------------------------------
>
> Key: MATH-1019
> URL: https://issues.apache.org/jira/browse/MATH-1019
> Project: Commons Math
> Issue Type: Bug
> Reporter: Gilles
> Fix For: 3.3
>
>
> The method does not abide by its contract: elements before the "end" index
> are included in the shuffle.
> {code}
> /**
> * Uses a 2-cycle permutation shuffle to randomly re-order the last elements
> * of list.
> *
> * @param list list to be shuffled
> * @param end element past which shuffling begins
> */
> private void shuffle(int[] list, int end) {
> int target = 0;
> for (int i = list.length - 1; i >= end; i--) {
> if (i == 0) { // XXX "0" should be "end"
> target = 0; // XXX "0" should be "end"
> } else {
> // NumberIsTooLargeException cannot occur
> target = nextInt(0, i); // XXX "0" should be "end"
> }
> int temp = list[target];
> list[target] = list[i];
> list[i] = temp;
> }
> }
> {code}
> I'm going to introduce the above corrections in the new implementation to be
> located in "MathArrays" (cf. issue MATH-1010).
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira