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)
so for example, if you want 10 random numbers from 1-100, you would do randInt(1,100,10)
- Ti newbie
- Newbie (Posts: 5)
- 19 Nov 2021 03:22:23 pm
- Last edited by Ti newbie on 19 Nov 2021 03:23:45 pm; edited 1 time in total
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?
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?
If you are trying to pick a single random entry out of a list, you want something like:
Code:
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:
Code:
L₁(randInt(1,dim(L₁
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
» 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
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