View Full Version : Mathematica: Random Numbers
Sarah rob
Feb26-11, 05:25 PM
I am trying to create a list of 5 random numbers between 1 and 20
In[62]:= RandomInteger[{1, 20}, 5]
Out[62]:= {10, 11, 9, 8, 1}
But is it possible to exclude the number 10 from appearing?
pmagunia
Feb26-11, 08:03 PM
I am more of an R person, but I'm sure there is some kind comparison operator. Something along the lines of
if ($x != 10)
print $x;
You can feed the output of the random number generator into the above code.
The ' != ' means 'not equal'.
You could choose a random index to an array of 19 numbers, which includes the numbers 1 thorugh 20, but not 10.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.