Random Integer Generator
by Edward Zechmann
23 Jan 2008
(Updated 20 Feb 2008)
This program quickly outputs n random integers in the specified range from a to b.
|
Watch this File
|
| File Information |
| Description |
The program quickly outputs n random integers in the range from a to b. The integers are drawn from a uniform distribution to make selection of integers equally probable.
This program is intended to be especially quick with very large ranges of integers and selecting only a very small number of those integers.
User specifies whether output is sorted or random order.
User specifies whether to remove duplicate integers or to allow duplicate integers. |
| Acknowledgements |
The author wishes to acknowledge the following in the creation of this submission:
MYRANDINT -- Random Integer Generation
|
| MATLAB release |
MATLAB 7.5 (R2007b)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (6) |
| 24 Jan 2008 |
Jos x@y.z
|
|
|
| 28 Jan 2008 |
John D'Errico
|
|
|
| 31 Jan 2008 |
John D'Errico
|
|
|
| 01 Feb 2008 |
John D'Errico
|
|
|
| 10 Nov 2009 |
Karim Mansour
|
|
|
| 08 Dec 2011 |
Tyler
|
|
|
| Updates |
| 25 Jan 2008 |
Added contributed code to make the program faster. Added examples to emphasize that the program is fast especially for large ranges of integers and only selecting a few. |
| 28 Jan 2008 |
Added two additional options:
1) The output can be sorted or random order
2) The output can have no duplicate integers or allow duplicate integers. |
| 29 Jan 2008 |
Updated program to include contributed code from John D'Errico. Fixed out of range bug. |
| 31 Jan 2008 |
Made the third regime a catch for the pure rejection regime. Program returns warnings when pure rejection fails to select enough integers and the catch cancels the error if successful. |
| 31 Jan 2008 |
Fixed a bug in outputting the proper size and orientation of the selected integers. Unfortunately, I was not able to recreate the bug that John D'Errico found. Hopefully, the bug was fixed by improving the resizing code. |
| 20 Feb 2008 |
Added an option to plot the integers. The plot is helpful in visually inspecting the distribution of the output. |
|
Contact us at files@mathworks.com