Post Reply 
Random Integers, No Repeats
08-09-2023, 05:10 PM
Post: #9
RE: Random Integers, No Repeats
(08-09-2023 04:59 PM)nickapos Wrote:  
(08-09-2023 04:54 AM)Joe Horn Wrote:  If you don't mind using an undocumented but stable CAS function, rand(X,Y,Z) returns X random integers between Y and Z without repeats. Example: rand(10,50,59) returns all 10 integers between 50 and 59 in random order. It's faster than creating an array and then shuffling it. rand(10000,1,10000) takes only 0.0072 seconds on a G2 Prime. Although it's a CAS function, it also seems to work in Home and in non-CAS programs.

Hey Joe, this is a great function. Do you happen to know what kind of seed is rand using?
Thanks and regards

No idea. The randseed() function doesn't seem to have any effect on the output of rand(X,Y,Z). Perhaps Bernard Parisse, who created Prime's CAS, can give us the details of how rand(X,Y,Z) works.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Random Integers, No Repeats - lrdheat - 08-09-2023, 02:30 AM
RE: Random Integers, No Repeats - Joe Horn - 08-09-2023, 04:54 AM
RE: Random Integers, No Repeats - nickapos - 08-09-2023, 04:59 PM
RE: Random Integers, No Repeats - Joe Horn - 08-09-2023 05:10 PM
RE: Random Integers, No Repeats - lrdheat - 08-09-2023, 01:24 PM
RE: Random Integers, No Repeats - Joe Horn - 08-09-2023, 05:31 PM
RE: Random Integers, No Repeats - nickapos - 08-09-2023, 06:04 PM
RE: Random Integers, No Repeats - parisse - 08-09-2023, 06:09 PM



User(s) browsing this thread: 2 Guest(s)