Random
Number Table
What
are random numbers?
This is
not a formal mathematical definition, but random numbers are sets of
digits generated,
arranged or chosen without somebody deciding in advance

its order or value, and
without any regular pattern. They are randomly sorted, and no
individual number
can be predicted from previous knowledge of any other number or group
of
digits.
What
is
a random number generator?
A
random number generator is an algorithm that produces random numbers.
Any
random process can be used to generate random numbers.

A computer
cannot
produce true random numbers and produces only pseudorandom numbers. A
computer
can reproduce the same sequence of digits if we repeat exactly the same
algorithm. Modern algorithms create the illusion of having a true
random
generator, but it’s only an illusion.
In
Matlab, there are two common functions for generating pseudorandom
numbers:
rand and randn.
Builtin
function rand
is meant for uniformly distributed pseudorandom numbers.
R = rand(N)
returns an NbyN matrix containing pseudorandom values drawn from a
uniform
distribution on the unit interval. rand(M, N) returns an MbyN matrix. rand(M, N, P,...) returns
an
MbyNbyPby... array. rand
with no
arguments returns a scalar. rand(size(A))
returns an array the same size as A.
Builtin
function randn
is meant for normally distributed pseudorandom numbers.
R = randn(N)
returns an NbyN matrix containing pseudorandom values drawn from a
normal
distribution with mean zero and std. deviation one.
randn(M, N) returns an MbyN matrix. randn(M,
N, P,...) returns an MbyNbyPby... array.
randn with no arguments returns a scalar.
randn(size(A)) returns an
array the same size as A.
Random
numbers table
A
random number table is a listing of random numbers where we can choose
the quantity
of random numbers desired, the maximum and minimum values of numbers in
the
table, and whether or not duplicate numbers are allowed.
If we
need to generate 100 uniform random numbers on the set 0 : 1 in Matlab,
we can
just type rand(100,
1).
If we
need to generate 10 uniform integers on the set 1 : n in Matlab, we can
do this
%
Choose your maximum integer, n
n
= 15;
%
Generate 10 integers, from 1 to n
f
=
ceil(n * rand(1, 10));
%
Display the first five elements in your table
f(1
: 5)
If we
have a specific group of numbers already defined in a table, and want
to make a
random selection of numbers in that table, we can generate a random
index and
then see what number of the table is the corresponding one.
For
example, let’s say that we have a vector x that has values from 10 to
10 in
0.05steps. We want to take three random elements from that table.
%
Vector from 10 to 10, in 0.05steps
x = 10
: 0.05 : 10;
%
Generate 3 random indices on the set 1 : length(x)
%
Display those indices, just to keep them visible
n =
length(x);
ix =
ceil(n * rand(1, 3))
%
Display our corresponding three xvalues
x(ix)
We get
from Matlab
ix
= 340
211
82
ans =
6.9500
0.5000
5.9500
This
means that our indices were randomly selected from all of the possible
indices
in x (401 possible integers, due to the size of the vector), and the
selected values were within
the [10, 10]
interval and were a multiple of 0.05, as per our specifications.
Of course, if you repeat the experiment, you're going to get different
indices and values.
Now,
let’s generate a uniform distribution of random numbers on a specified
interval
[a, b]. To do this, multiply the output of rand by (ba), then add a.
For
example, to generate a 4by3 array of uniformly distributed random
numbers on
the interval [20, 95], we can type
a
= 20;
b = 95;
x = a +
(b  a) * rand(4, 3)
and we
could get
x
=
35.5350
63.1361
43.4514
65.5399
53.8569
20.9647
67.2416
23.2921
48.7975
47.7858
22.0389
71.2337
Think of using builtin functions ceil, floor, unique, intersect,
union and others to work with specific subgroups of your numbers, or
when you have a number of different matrices and want to compare or
separate your results.
From
'Random Number Table' to home
From 'Random Number
Table' to Probability and Stats
