Mathematica:are nonrepeatative random numbers possible?

  • Mathematica
  • Thread starter Sarah rob
  • Start date
  • #1
16
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
 

Answers and Replies

  • #2
1,069
29
list1=RandomInteger[{1, 7}, 10];
list2=Sort[RandomSample[Range[30],10]];
Transpose[{list1,list2}]
 

Related Threads on Mathematica:are nonrepeatative random numbers possible?

  • Last Post
Replies
1
Views
2K
Replies
2
Views
2K
  • Last Post
Replies
2
Views
1K
Replies
4
Views
2K
Replies
0
Views
1K
Replies
1
Views
2K
Replies
6
Views
5K
Replies
4
Views
2K
Top