Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Bug with RandomSample ?' topicStudent Support Forum > General > Archives > "Bug with RandomSample ?"

Next Comment >Help | Reply To Topic
Author Comment/Response
06/28/08 03:35am


I am currently using RandomSample to take a set of elements from a list. There seem to be a problem, or I missed something.

Consider this command:
Length[Union[RandomSample[Range[12]^341, 8]]]
This is expected to return 8, since we want a sample of 8 elements from a list of 12 elements. The result is fine.

Now, consider this command:
Length[Union[RandomSample[Join[Range[12]^341, {1, 1, 1}], 8]]]
I just add some other values, 1, which are really different from the other ones, and the result seems weird to me: if you evaluate 10 times this command, you can get "6", "7" or "8" ... though I would expect only "8" as a result.

Is it a problem of Mathematica or have I missed something ? Thanks for your help.



Subject (listing for 'Bug with RandomSample ?')
Author Date Posted
Bug with RandomSample ? Xavier 06/28/08 03:35am
Re: Bug with RandomSample ? Gopinath Ven... 06/28/08 6:33pm
Re: Bug with RandomSample ? S. Saralamba 06/30/08 9:21pm
Re: Bug with RandomSample ? Xavier 07/02/08 00:13am
Next Comment >Help | Reply To Topic