Jump to content

Talk:Random permutation

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Untitled

[edit]

How much needs to be in this article before the stub notice is removed? We could go on and on about random permutations, but I don't think the article should be too long... --Adking80 20:17, 28 Mar 2005 (UTC)


the Knuth shuffle, is to start with the identity permutation, and then go through the positions 1 through n ... I would say to n-1 (there is no shuffle for a single member permutaion). Cepek 12:45, 25 February 2007 (UTC)[reply]


The article is inconsistent where it says (a) "It requires a function uniform(m) which returns a random integer between 0 and m inclusive." and (b) "unsigned uniform(unsigned m); /* Returns a random integer 0 <= uniform(m) < m */" The first statement says that both 0 and m are within range, but the the second statement says that m is excluded.

Knuth shuffle code is wrong. The swap position j should be from i to (n-1). Btw. it is often convention that uniform(m) picks among m numbers, i.e. 0...(m-1) or 1...m. Also, I will link to the existing wikipedia article on Knuth / Fisher–Yates shuffle. There the possible biases are discussed in detail. — Preceding unsigned comment added by 141.89.116.54 (talk) 10:00, 9 February 2015 (UTC)[reply]

The Knuth shuffle example was intended to show the "inside-out" variant where initialization of the array is combined with the shuffle, rather than a pure shuffle of an existing array (which got broken by the 2014/11/30 edit). Either the text should be changed to remove discussion of the improved algorithm ("The initialization to the identity permutation and the shuffling may be combined, as in the following example."), or the example code should reflect the text. I like the latter option better. Regarding the definition of uniform(m), I think defining uniform(m) to generate 0 to m inclusive is easier to understand than defining it to generate 0 to m-1 and then using uniform(i+1) in the code. Henry stuffedcow (talk) 19:40, 26 July 2015 (UTC)[reply]
As seems to no one is going to repair this (a year after someone spotted the error and two years after the wrong code was introduced to the article... I can't imagine how much javascript code is now out there with this wrong algorithm:) I have done the minimal necessary corrections. The original algorithm, that perform a permutation to any given set, is much more important than inside-out version, so I used this version. In the form "0 to n-2", see https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modern_method . To avoid confusion I modified the text to 'index form 0' convention - the same as used in the pseudocode. If someone want to introduce the correct inside-out version, I think it should be done by adding the second code, not by overwriting this one. Bartekltg (talk) 23:40, 22 April 2016 (UTC)[reply]

Wiki Education Foundation-supported course assignment

[edit]

This article was the subject of a Wiki Education Foundation-supported course assignment, between 26 May 2020 and 3 July 2020. Further details are available on the course page. Student editor(s): Yifeng Li.

Above undated message substituted from Template:Dashboard.wikiedu.org assignment by PrimeBOT (talk) 07:48, 17 January 2022 (UTC)[reply]

What is this scrambling algorithm?

[edit]

https://scratch.mit.edu/projects/191308642/

Instructions: Generate a nearly sorted list, then use bogo sort. Identify the scrambling algorithm used. 83.31.148.107 (talk) 09:19, 28 December 2017 (UTC)[reply]

Oh, and while you're at it, identify the scramble in Sound Of Sorting, a downloaded program: http://panthema.net/2013/sound-of-sorting/

The instructions are similar, except with reversed list instead of the non-available nearly sorted. 83.31.148.107 (talk) 09:23, 28 December 2017 (UTC)[reply]

[edit]

https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle seems to describe the same algorithm. Why there is no link? — Preceding unsigned comment added by 158.129.140.119 (talk) 16:25, 15 February 2019 (UTC)[reply]

This article includes the link Knuth shuffle, which is a redirect to that article. --JBL (talk) 16:41, 15 February 2019 (UTC)[reply]