Resources

How to create random integers within a specific range?

1

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?

asked August 30, 2012
admin
27

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));
admin
27