in reply to Re^2: Generating 0 .. N Randomly and Efficiently
in thread Generating 0 .. N Randomly and Efficiently
In your example, all unchosen numbers would have the same probability of being selected.Yes, that's my point ;)
...this is much closer to being random then you are giving it credit for...<nitpick>The selection point itself is random
The direction to choose from is random...still random (just not statistically uniform)...
Then you need to qualify your use of the word "random." In the context of selecting things at "random," the word is meaningless without a probability distribution. If the distribution is not specified, then the only reasonable probability distribution to assume is the uniform distribution. It usually doesn't make sense to choose from a finite set of objects in a nonuniform way. It is for this reason that in CS we often say "choose at random" to implicitly mean "choose uniformly at random."
But please, do not use an unqualified "random" to mean "complicated to predict" or "generated by a process that uses the random number generator" or even "chosen according to some probability distribution that assigns positive probability to all outcomes." Yes there is a difference, and this is where confusions start.
Yes indeed, for many cases, your code would be "random enough," in that the probability of most permutations is not hugely different from 1/N!. But is this "random enough?"
Well, it's random, but not uniform. It just happens to follow my personal favorite probability distribution ;) If there is a criteria for being "random enough", then you'd have to define what it means for a probability distribution to be "random enough" and then show convincingly that your code follows it!sub random_perm { my $n = shift; return rand() < 0.2 ? (1 .. $n) : reverse (1 .. $n); }
Basically my point is that choosing something "randomly enough" or "close to randomly" or whatever is a meaningless expression, and the concept behind it is shaky.
</nitpick>
Anyway, I realize this is a little tangential from the topic at hand and I take full responsibility for jumping all over it. But I often see this term misused/abused and wanted to have my thoughts on public record ;) What were we talking about again? Oh yes, permutations using no memory ;)
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Generating 0 .. N Randomly and Efficiently
by Limbic~Region (Chancellor) on Oct 19, 2004 at 19:50 UTC | |
by tilly (Archbishop) on Oct 20, 2004 at 19:33 UTC |