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 pseudo-random 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 pseudo-random numbers: rand and randn.

Built-in function rand is meant for uniformly distributed pseudo-random numbers. R = rand(N) returns an N-by-N matrix containing pseudo-random values drawn from a uniform distribution on the unit interval. rand(M, N) returns an M-by-N matrix. rand(M, N, P,...) returns an M-by-N-by-P-by-... array. rand with no arguments returns a scalar. rand(size(A)) returns an array the same size as A.

Built-in function randn is meant for normally distributed pseudo-random numbers. R = randn(N) returns an N-by-N matrix containing pseudo-random values drawn from a normal distribution with mean zero and std. deviation one. randn(M, N) returns an M-by-N matrix. randn(M, N, P,...) returns an M-by-N-by-P-by-... 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.05-steps. We want to take three random elements from that table.

% Vector from -10 to 10, in 0.05-steps
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 x-values
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 (b-a), then add a. For example, to generate a 4-by-3 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 built-in functions ceil, floor, unique, intersect, union and others to work with specific sub-groups 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

 Top Simulations with numbers Online Statistical Calculators

Related pages

boolean axiomscalculus integration calculatorstd matlabcalculus half life formulaconvert binary to octalmatlab curve fitting exponentialresistance color code formuladepreciation salvage value formuladivide the polynomialsinverse matrix gauss jordansolve definite integrals onlineresistor color coding formulascilab programsfactorial matlabgauss jordan inverse calculatorgray code to binary conversionpolynomial interpolation matlab codeinterest calculation spreadsheetinverse function in matlabhow to convert binary to grey codeannuity functionif statements matlabdepreciated value formulafinding the roots of a quadratic equation calculatoraddition of two numbers in matlabvector multiplication matlabinverse a matrix in matlabsketch piecewise functionsolve 3 simultaneous equations onlineeuclidean algorithmswriting a program in matlabbmi calculator javascript codequadratic equation calckronecker delta functionhow to convert binary to decimal numbersconvert polar coordinates to cartesianlinear regression with matlabascii values of alphabetsgaussian elimination in matlabmatlab gui exampletrapezoidal rule programconvert from octal to binaryhome amortization tablesolving a matrix in matlabdiscrete distribution calculatortable matlabconverting gray code to binarysolving system of equations in matlabsolve nonlinear equations matlabfind gcd using euclidean algorithmterm deposit calculator excelwrite a piecewise functionsvd examplematlab solve linear equationsmultiple regression in matlabsketching piecewise functionsregression in matlabhow to define step function in matlaberrordlg matlabbinary to octal tablematrix simultaneous equations calculatordecimal to octal tablesolving rc circuit differential equationchange binary to decimal3 bit binary to gray code convertermatlab txt3n 1 conjecturegauss jordan matrixsum of infinite geometric series examplesmatlab plot exponential functionsimple gui program in matlabrc circuit practice problems