Mathematica:are nonrepeatative random numbers possible?

  • Context: Mathematica 
  • Thread starter Thread starter Sarah rob
  • Start date Start date
  • Tags Tags
    Numbers Random
Click For Summary
SUMMARY

The discussion focuses on generating two lists of random numbers using Mathematica, specifically the functions RandomInteger and RandomSample. The first list is created using RandomInteger[{1, 7}, 10], resulting in potentially duplicate values. The second list aims to generate 10 unique numbers from 1 to 30, which can be achieved with Sort[RandomSample[Range[30], 10]]. Finally, the two lists can be combined into pairs using Transpose[{list1, list2}].

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of random number generation functions in Mathematica
  • Knowledge of list manipulation techniques in Mathematica
  • Basic understanding of sorting algorithms
NEXT STEPS
  • Explore the RandomSample function in Mathematica for unique random selections
  • Learn about list manipulation functions such as Transpose and Table in Mathematica
  • Investigate sorting methods and their applications in Mathematica
  • Study advanced random number generation techniques in Mathematica
USEFUL FOR

Mathematica users, data scientists, and programmers interested in random number generation and list manipulation techniques.

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

Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
10
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K