The rndi function creates random integers, but I need to create a vector of random integers within a specific range such as between 1 and 30. How can I do this in GAUSS?
1 Answer
0
You can create random integers with a range of [1, maxRange] by multiplying a vector of uniform random numbers by maxRange and then applying the ceil function to round these numbers up to the next whole number. For example to create 40 random integers between 1 and 30, you could:
r = ceil(30 * rndu(40, 1));
Your Answer
1 Answer
You can create random integers with a range of [1, maxRange] by multiplying a vector of uniform random numbers by maxRange and then applying the ceil function to round these numbers up to the next whole number. For example to create 40 random integers between 1 and 30, you could:
r = ceil(30 * rndu(40, 1));