Mathematica Mathematica:are nonrepeatative random numbers possible?

  • Thread starter Thread starter Sarah rob
  • Start date Start date
  • Tags Tags
    Numbers Random
AI Thread Summary
To generate two lists of random numbers in Mathematica, the first list can be created using RandomInteger[{1, 7}, 10]. For the second list, to ensure all numbers are different and sorted, use RandomSample[Range[30], 10]. To combine the two lists into pairs, the Transpose function can be applied to the lists. The final code snippet would be: list1 = RandomInteger[{1, 7}, 10]; list2 = Sort[RandomSample[Range[30], 10]]; Transpose[{list1, list2}]. This approach effectively creates the desired output of paired random numbers.
Sarah rob
Messages
16
Reaction score
0
I am trying to create 2 list of random numbers of the same length
The 1st list random list i can do
RandomIntegerRandomInteger[{1, 7}, 10]
to get {6, 5, 4, 7, 2, 1, 5, 5, 2, 6}

the 2nd list however i want 10 numbers from 1-30 that are all different and in order,
what do i need to add to Sort[RandomInteger[{1, 30}, 10]]
at the moment i am getting list such as
{5, 7, 10, 21, 21, 22, 22, 25, 28, 30}

Also is there a way to then join the 2 list so that they appear in a list of pairs
e.g. {{6,5},{5,7},{4,10}}
ive tried to use Table but not having much success
 
Physics news on Phys.org
list1=RandomInteger[{1, 7}, 10];
list2=Sort[RandomSample[Range[30],10]];
Transpose[{list1,list2}]
 

Similar threads

Back
Top