Hi, does anyone know how to use randint for lists? I keep trying, but all I get are zeroes and ones.
randInt(lowerbound,upperbound,number of elements)
so for example, if you want 10 random numbers from 1-100, you would do randInt(1,100,10)
Would I be able to use a list? (E.x. Randint(1,L5),and be able to pull one number out of that, or could I use specific numbers?
You need to select an entry out of the list to set the max- i.e. L5(1
Ok. Thank you so much!
Oxiti8 wrote:
You need to select an entry out of the list to set the max- i.e. L5(1


Can I exclude certain numbers from the randint?
Ti newbie wrote:
Oxiti8 wrote:
You need to select an entry out of the list to set the max- i.e. L5(1


Can I exclude certain numbers from the randint?

No. You can only set the maximum and minimum.
Oxiti8 wrote:
You need to select an entry out of the list to set the max- i.e. L5(1


Can I exclude certain numbers from the randint?
To choose a random list element:
Code:
L₅(randInt(1,dim(L₅
If you are trying to pick a single random entry out of a list, you want something like:
Code:
L₁(randInt(1,dim(L₁
That is, randInt should be used to pick the index into the list, because it cannot pick an element out of a list directly.

If you want more than one random entry out of a list (with or without replacement), you can generate multiple indices using randInt (with replacement) or randIntNoRep (without replacement) & then use a loop to do the indexing to collect the elements into a new list.

If what you want is a random number between the lowest & highest elements in a list (regardless of whether that exact number appears in the list), you want something like:

Code:
randInt(min(L₁),max(L₁
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement