|
-
Jul 17th, 2005, 09:32 PM
#1
Thread Starter
Dazed Member
shuffle(List<?> list, Random rnd)?
Ive been wondering what the random number generator thats used as an arg to the shuffle method applies to. Does it apply to the probability that a List will have it's elements end up in the same sequence after being shuffled multiple times? If so how can the probability be increased or decreased? Thanks.
-
Jul 18th, 2005, 01:55 AM
#2
Re: shuffle(List<?> list, Random rnd)?
I think it is just that random object it uses for the shuffeling. So it has nothing to do with probability. So I guess that if you seed the random object with the same number 2 times, and pass it into the shuffle method, then you will get the same order. If you do not seed it with the same number, then you will get different (at least in theory) order of the elements.
- ØØ -
-
Jul 18th, 2005, 12:09 PM
#3
Re: shuffle(List<?> list, Random rnd)?
A typical shuffling algo looks like this:
Code:
for i is 0 to list size do
j = random between 0 and list size
swap list[i] and list[j]
done
The Random object is the source of the random numbers.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 18th, 2005, 12:20 PM
#4
Re: shuffle(List<?> list, Random rnd)?
So I guess my seeding theory holds...
- ØØ -
-
Jul 18th, 2005, 03:12 PM
#5
Thread Starter
Dazed Member
Re: shuffle(List<?> list, Random rnd)?
Posted by NoteMe
So I guess that if you seed the random object with the same number 2 times, and pass it into the shuffle method, then you will get the same order.
Yes according to java.util.Random docs that is correct.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|