I don't know what Grime's second post is implying, but the issue is the if (r == 9) ++ r; implementation makes the distribution significantly non-uniform (well, more non-uniform than just using % 10 to begin with).
(I misread the post, please just ignore this post.)
Now, maybe that doesn't matter for Chris26's purposes.
There might be a better way to implement whatever Chris is trying to do, such as changing the logic a bit to allow shuffling.
some sequences all I know to do is prepopulate a vector and get a random *index* into the list.
this isnt one of those problems, but say you needed to choose a random value from {1,7,13,18,32,100} ... its easier to just get a random value from 0 to 5 and pick off the value from your list. Just in case you run into this kind of problem again.
Yes, if the pool of possible numbers is small enough, producing a uniform random index into an arbitrary list would be preferred. But if the pool of numbers is absurdly large, then either the loop or making the distribution slightly non-uniform would be preferred.
the issue is the if (r == 9) ++ r; implementation makes the distribution significantly non-uniform (well, more non-uniform than just using % 10 to begin with).
No, it doesn't. If you have a generator that selects an element from the set {1, 2, 3, 4, 5, 6, 7, 8, 9}, adding if (r == 9) ++r; after the generation transforms the selection set to {1, 2, 3, 4, 5, 6, 7, 8, 10} without altering the uniformity for elements 1-8 and moves the uniformity of 9 to 10. In other words,
P'(1) = P(1)
P'(2) = P(2)
P'(3) = P(3)
P'(4) = P(4)
P'(5) = P(5)
P'(6) = P(6)
P'(7) = P(7)
P'(8) = P(8)
P'(10) = P(9)
I've noticed that you aren't that bright, but this is a new low for you.
You just had to say "no". Two letters, would take you what 250 milliseconds max?
I can see that you're perfect and never misread anything, and for that I congratulate you.
I've noticed you saying a number of stupid things. You are an idiot. That's what I was trying to say. I hope that's clear to you now. Moron. :-)
Surely insulting other people isn't a "stupid" thing to do. Anyways you be you and I'll be me. At the end of the day you're some stranger and I'm some stranger.