[go: up one dir, main page]

0% found this document useful (0 votes)
25 views18 pages

Random Number Generation

Uploaded by

kilesa7537
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views18 pages

Random Number Generation

Uploaded by

kilesa7537
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

4.

0 RANDOM NUMBERS

4.1. Introduction
The use of Random numbers lies at the heart modeling and simulation. Computer
applications such as simulations, games, graphics, etc., often need the ability to generate
random numbers for such application.
The quality of a random number generator is proportional to its period, or the number of
random numbers it can produce before a repeating pattern sets in. In large-scale simulations,
different algorithms (called shift-register and lagged-Fibonacci) can be used, although these
also have some drawbacks, combining two different types of generators may produce the best
results.

4.2 Desirable Properties of a Good Random Number Generator


The random numbers generated should have:
1. Speed: The generator should be fast to avoid the need for a lot of storage. Should not
require large amounts of memory
2. Be able to generate a different set of random numbers or a series of numbers
3. Periodicity: The generator should have a long period i.e. produce a long sequence of
numbers before the sequence begins a cycle. The method should not degenerate to
repeatedly produce a constant value.
4. The generator should be able to produce a different set of random numbers to reproduce
a series of numbers depending on where it starts the sequence.
5. Uniform distribution: The numbers produced should appear to be distributed uniformly
on [0,1] and should not exhibit any correlation with each other; otherwise simulation
results may be completely invalid.
6. Reproduction: It should be possible to reproduce a given stream of random numbers
exactly. This makes debugging and verification of the program easier. Also, it may be
necessary to use identical random numbers in simulating different systems in order to
obtain more precise comparisons.
7. Portability: The generator should be portable i.e. produce the same sequence of random
numbers for all standard computers.

4.3. How to generate random numbers


Random Number can be defined as numbers that show no consistent pattern, with each number
in a series and are neither affected in any way by the preceding number, nor predictable from it.

1
One way to get random digits is to simply start with an arbitrary number with a specified
number of digits, for example 4 digits. The first number is called the seed. The seed is
multiplied by a constant number of the same number of digits (length), and the desired number
of digits is taken off the right end of the product. The result becomes the new seed.

It is again multiplied by the original constant to generate a new product, and the process is
repeated as often as desired. The result is a series of digits that appear randomly distributed as
though generated by throwing a die or spinning a wheel. This type of algorithm is called a
congruential generator
The so-called true random number generators extract random numbers from physical
phenomena such as a radioactive source or even atmospheric noise as detected by a radio
receiver.

4.4. Pseudorandom Number Generation (PRN)

PRN is a set of values or elements that is statistically random, but it is derived from a known
starting point and is typically repeated over and over. It is called "pseudo" random, because the
algorithm can repeat the sequence, and the numbers are thus not entirely random.

What we usually do is to take for instance ten pieces of papers and number them
0,1,2,3,4,5,6,7,8, and 9 , fold and place them in a box. Shake the box and thoroughly mix the
slips of paper. Select a slip; then record the number that is on it. Replace the slip and repeat this
procedure over and over.
The resultant record of digits is a realized sequence of random numbers. Assuming you
thoroughly mix the slips before every draw, the nth digit of the sequence has an equal or
uniform chance of being any of the digits 0,1,2,3,4,5,6,7,8, and 9 irrespective of all the
preceding digits in the recorded sequence.

Problems when generating pseudo-random numbers


i. The generated numbers might not be uniformly distributed
ii. The generated numbers might be discrete-valued instead of continuous-valued
iii. The mean of the generated numbers might be too high or too low
iv. The variance of the generated numbers might be too high or too low
v. Independence might not hold.

2
True random number generators (TRNGs):
Truly random is defined as exhibiting “true” randomness. This type uses a physical source of
randomness to provide truly unpredictable numbers. TRNGs are mainly used for cryptography,
because they are too slow for simulation purposes. Many true random number generators are
hardware solutions that you plug to a computer. The usual method is to amplify noise generated
by a resistor (Johnson noise) or a semi-conductor diode and feed this to a comparator or Schmitt
trigger. Once you sample the output, you get a series of bits which can be used to generate
random numbers. True random number generators can be used for research, modeling,
encryption, lottery prediction and parapsychological testing, among many other uses.

4.5. Random Numbers in Computer


How does computer generate a sequence of random numbers?
One way is to perform the above “slip-in-a-box” experiment and then store the recorded
sequence in a computer-backing store. The RAND Corporation using specially designed
electronic equipment, to perform the experiment, actually did generate a table of a million
random digits. The table can be obtained on tape, so that blocks of the numbers can be read into
the memory of a high- speed computer, as they are needed. Their approach is disadvantageous
since considerable computer time was expended in the delays of reading numbers into memory
from a tape drive.
Experts in computer science have devised mathematical processes for generating digits
that yield sequences satisfying many of the statistical properties of a truly random process.
Since such a process is not really random, it is called pseudo-random number generator.

Most programing languages have built-in random number generators (Excel, Matlab all have it).
In Matlab, the command rand (1) returns a random number between 0 and 1 assuming uniform
distribution. We can build other random variables using rand. For example, to get a random
number between a and b we can use a+rand(1)(b − a). To get a 0 or 1 on a random way in
Matlab, you can use round(rand(1)). The function round(x) returns 0 of x ≤ 1/2 and returns 1 if x
> 1/2.
The function round is built-in in Matlab so you can use it without entering the M-file round
given below.
function y=round(x)
if x<=1/2
y=0;
else y=1;

3
end
Microsoft Excel has a numeric function named RAND, which generates random
numbers between 0 and 1. Each time RAND is executed, a pseudo random number
between 0 and 1 is generated. RAND returns an evenly distributed random real
number greater than or equal to 0 and less than 1. A new random real number is
returned every time the worksheet is calculated. RAND uses the following syntax:
RAND (). The RAND function syntax has no arguments.
Using RAND function at any time will always generate the same sequence of
pseudo random numbers unless we vary the random number seed using the Excel
statement: To generate a random real number between a and b, use: RAND ()*(b-a)+a
If you want to use RAND to generate a random number but don't want the numbers to
change every time the cell is calculated, you can enter =RAND() in the formula bar,
and then press F9 to change the formula to a random number.

Example
Table 1: Formula and Description

Formula Description Result

=RAND() A random number greater than or equal to 0 and less than 1 (varies) varies

=RAND()*100 A random number greater than or equal to 0 but less than 100 (varies) varies

4.7. Simulating Randomness


Suppose we want to simulate the throwing of a fair die. A random number between 0
and 1 will not always satisfy our needs. If the die is fair, throwing it several times will yield a
series of uniformly distributed integers 1, 2,3,4,5 and 6. Consequently we need to be able to
generate a random integer with values in the range 1 and 6 inclusive.

Now the function RAND generates a random number between 0 and 1. Specifically, the
random variable X is in the range: 0 < X < 1. The expression X= RAND ()*6. Will generate a
number in the range: 0 < X < 6.

4.8 Methods of Generating Random Numbers


The following are methods of generating random numbers:
1. Linear Congruential Method
4
2. Quadratic Congruential Method
3. Mid-square method
4. Mid-product Method
5. Fibonnachi Method
6. Multiplicative Congruential

4.8.1 The Linear Congruential Method


A linear congruential generator (LCG) is an algorithm that yields a sequence of pseudo-
randomized numbers calculated with a discontinuous piecewise linear equation. The method
represents one of the oldest and best-known pseudorandom number generator algorithms. The
theory behind them is relatively easy to understand, and they are easily implemented and fast,
especially on computer hardware which can provide modulo arithmetic by storage-bit truncation.

The generator is defined by the recurrence relation:

where is the sequence of pseudorandom values, and

– the "modulus"
– the "multiplier"
– the "increment"
– the "seed" or "start value"

The random integers are being generated [0,m-1], and to convert the integers to random numbers:
Ri = Xi/m

Example 1

Given X0 = 27, a = 17, c = 43, and m = 100. Generate random numbers.

Solution
The Xi and Ri values are:
X1 = (17*27+43) mod 100 = 502 mod 100 = 2, R1 = 0.02;
X2 = (17*2+43) mod 100 = 77, R2 = 0.77;
X3 = (17*77+43) mod 100 = 52, R3 = 0.52;
X3 = (17*52+43) mod 100 = 27, R4 = 0.27;

Example
eg x0=1, a=2, c=3, m=5 (ans =0)

5
x1=0
x2=3
x3=4
x4=1

Example
For example, the sequence obtained
•when X0 = a = c = 7, m = 10
•Required: Generate six random numbers
Solution

Example
As an example, using our Linear congruential formula
•Xn+1 = (aXn+c) (modulo m),
•And suppose m = 8, a = 5, c = 7 and X0 (seed) = 4
•Generate 7 random numbers using congruential formula above

6
Example
For example, the sequence obtained when m = 10 and X0 = a = c = 7 is 7,6,9,0,7,6,9,0,………..

As this example shows, the sequence is not always "random" for all choices of m, a, c, and X 0.
This illustrates the fact that the congruential sequences always "get into a loop"; i.e., there is
ultimately a cycle of numbers that is repeated endlessly. This property is common to all
sequences having the general form Xn+1 = f(Xn); the repeating cycle is called the period;
sequence (2) has a period of length 4. A useful sequence will of course have a relatively long
period.
Exercise

i) Use X =2, a = 13, c = 0, and m = 64


ii) Produce a table of random numbers using Linear congruential method, using a =5, m =8 and
X0 = 4. Draw an inference from your solution.

Merits and Demerits of LCG


 LCGs are fast and require minimal memory (typically 32 or 64 bits) to retain state. This
makes them valuable for simulating multiple independent streams.
 Linear congruential random number generators are widely used in simulation. Because
they are very fast, and because they have minimal state space, they remain attractive for
use in parallel computing environments.
 LCGs should not be used for applications where high-quality randomness is critical. For
example, it is not suitable for a Monte Carlo simulation because of the serial correlation
(among other things). They should also not be used for cryptographic applications.
 LCGs tend to exhibit some severe defects. For instance, if an LCG is used to choose
points in an n-dimensional space, the points will lie on, at most, m1/n hyper planes
(Marsaglia's Theorem, developed by George Marsaglia). This is due to serial correlation
between successive values of the sequence Xn. The spectral test, which is a simple test of
an LCG's quality, is based on this fact.
 A further problem of LCGs is that the lower-order bits of the generated sequence have a
far shorter period than the sequence as a whole if m is set to a power of 2.
 In general, the nth least significant digit in the base b representation of the output
sequence, where bk = m for some integer k, repeats with at most period bn
 Nevertheless, LCGs may be a good option. For instance, in an embedded system, the
amount of memory available is often very severely limited. Similarly, in an environment
such as a video game console taking a small number of high-order bits of an LCG may
well suffice. The low-order bits of LCGs when m is a power of 2 should never be relied
on for any degree of randomness whatsoever. Indeed, simply substituting 2n

7
4.8.2. The Quadratic congruential method
This method uses the formula:
Xn=1 = (dX 2+ cXn + a) n modulo m
Where d is chosen in the same way as c and m should be a power of 2 for the method to
yield satisfactory results.

4.8.3. The Mid-square method


The mid square method was proposed by Von-Newmann and Metropolis in 1946. In this
method of random number generation, an initial seed is assumed and that number is squared.
The middle four digits of the squared value are taken as the first random number. Next, the
random number which is generated most recently is again squared and the middle most four
digits of this squared value are assumed as the next random number.
This is to be repeated to generate the required number of random numbers.
The formula is: Xn+1 =nX 2

This method is demonstrated as shown in Table below by assuming the initial seed as 8765

Example 2:
 Given the seed X0=7182, generate 7 random numbers using Mid square method

8
Limitations
 The mid-square method is rarely used these days as it has the tendency to degenerate
rapidly.
 Also, if the number zero is ever generated, then all subsequent numbers generated will
be zero.
 Furthermore, the method is slow when simulated in the computer since many
multiplications and divisions are required to access the middle four digits.
 There is no relationship between the initial seed and the length of the sequence of
random numbers

4.8.4. The mid-product method


This method is similar to the mid-square method, except that a successive random number is
obtained by multiplying the current number by a constant c, and taking the middle digits.
The formula is: Xn+1 = cXn
The mid-product method has a longer period and it is more uniformly distributed than the
mid-square method.

4.8.5. The Fibonacci method


The simplest sequence in which Xn+1 depends on more than one of the preceding values is the
Fibonacci sequence,
Xn+1 = (Xn + Xn−1) mod m. …………………………….
This generator was considered in the early 1950s, and it usually gives a period length greater
than m; but tests have shown that the numbers produced by the Fibonacci recurrence are
definitely not satisfactorily random.

9
Problems with Fibonacci Generator (FG):
 The initialization of FGs is a very complex problem. The output of FGs is very sensitive
to initial conditions, and statistical defects may appear initially but also periodically in the
output sequence unless extreme care is taken.
 Another potential problem with FGs is that the mathematical theory behind them is
incomplete, making it necessary to rely on statistical tests rather than theoretical
performance
From the foregoing discussions, it is obvious that the last three methods – mid-square, mid-
product and Fibonacci are of historical significance and have detrimental and limiting
characteristics.

4.8.6 Multiplicative Congruential


Multiplicative congruential generators, also known as Lehmer random number generator, is a
type of linear congruential generator for generating pseudorandom numbers in U(0, 1)U(0, 1).
The multiplicative congruential generator, often abbreviated as MLCG or MCG, is defined as a
recurrence relation similar to the LCG with c = 0.
Xn+1=aXn mod m
Unlike the LCG, the parameters aa and mm for multiplicative congruential generators are more
restricted and the initial seed X0X0 must be relatively prime to the modulus mm (the greatest
common divisor between X0 and m is 0). The current parameters in common use are
m =231 − 1 = 2147483647 and a = 75 = 16807.

Exercises
1. Write an Excel program using Quadratic congruential method to generate 15 random
integer numbers between 1 and 50.
2. Produce a table of random numbers using multiplicative congruential method, using a
=5, m =8 and X0 = 4. Draw an inference from your solution.
3. Write a Excel function that can be referenced as computer random number between 30
and 100 using mixed congruential method.
4. Use the mixed congruential method to generate the following sequences of random
numbers:
a. A sequence of 10 one-digit random numbers given that

X
n+1 (Xn + 3)(modulo 10) and X0 = 2
b. A sequence of eight random numbers between 0 and 7 given that

10
X
n+1 (5Xn + 1)(modulo 8) and X0 = 4
c. A sequence of two-digit random numbers such that

X
n+1 (61Xn + 27)(modulo 100) and X0 = 40
d. A sequence of five-digit random numbers such that

X
n+1 (21Xn + 53)(modulo 100) and X0 = 33
u = r x 10-1
n n

where r = 100003r (modulo 1010), and r = any odd number not divisible by 5, then the
n n-1 0
period of the sequence will be 5 x 10 , that is r = r for the first time at n = 5 x 108 and the
8

n 0
cycle subsequently repeat itself. As an example, using our mixed congruential formula
Xn+1 = (aXn+c) (modulo m),
And suppose m = 8, a = 5, c = 7 and X0 (seed) = 4 we can generate a random sequence
of integer numbers thus:
Table 2: Random sequence of integer numbers
n Xn+1 = (5Xn+7)mod 8
0 X1 = (5*X0+7)mod 8 = (5*X4+7)mod 8 = 27 mod 8 = 3

1 X2 = (5*X1+7)mod 8 = (5*X3+7)mod 8 = 22 mod 8 = 6

2 X3 = (5*X2+7)mod 8 = (5*X6+7)mod 8 = 37 mod 8 = 5

3 X4 = (5*X3+7)mod 8 = (5*X5+7)mod 8 = 32 mod 8 = 0

4 X5 = (5*X4+7)mod 8 = (5*X0+7)mod 8 = 7 mod 8 = 7

5 X6 = (5*X5+7)mod 8 = (5*X7+7)mod 8 = 42 mod 8 = 2

6 X7 = (5*X6+7)mod 8 = (5*X2+7)mod 8 = 17 mod 8 = 1

7 X8 = (5*X7+7)mod 8 = (5*X1+7)mod 8 = 12 mod 8 = 4

Note that the value of X8 is 4, which is the value of the seed X0. So if we compute X9, X10, etc
the same random numbers 3, 6,5,0,7,2,1,4 will be generated once more. Note also that if we
divide the random integer values by 8, we obtain random numbers in the range 0 < Xn+1 < 1
which is similar to using the RAND function of Excel

4.9 Applications of random numbers


Numbers that are "chosen at random" are useful in many different kinds of applications.
For example:

11
 Simulation: When a computer is being used to simulate natural phenomena, random
numbers are required to make things realistic. Simulation covers many fields, from the
study of nuclear physics (where particles are subject to random collisions) to
operations research (where people come into, say, an airport at random intervals).
 Sampling: It is often impractical to examine all possible cases, but a random sample
will provide insight into what constitutes "typical" behavior.

 Numerical analysis: Ingenious techniques for solving complicated numerical problems


have been devised using random numbers.

 Computer programming: Random values make a good source of data for testing the
effectiveness of computer algorithms.
 Decision making: Sometimes it is important to make a completely "unbiased decision;
this ability is occasionally useful in computer algorithms, for example in situations
where a fixed decision made each time would cause the algorithm to run more slowly.
Randomness is also an essential part of optimal strategies in the theory of games.
 Recreation: Rolling dice, shuffling decks of cards, spinning roulette wheels, etc., are
fascinating pastimes for just about everybody.

4.10 Statistical Test for Pseudo – Random Number Generator


A randomness test (or test for randomness) is a test used to analyze the distribution of a set of
data to see if it can be described as random (pattern-less). When a random number generator is
devised, one needs to test its property. The two properties we are concerned most are uniformity
and independence. We have the following five statistical tests.
i) Frequency test
ii) Serial test
iii) Runs test
iv) Gaps test
v) Poker Test
vi) Tests for Auto-correlation

(i) Frequency test


The frequency test is a test of uniformity. This is one of the most fundamental tests for pseudo-
random number generators. Thus if PNG fails this test, then it is highly likely that it will also fail
more sophisticated tests.

In a true random sequence the number of 1’s & 0’s should be about the same. This test checks
whether this in true or not.

12
To achieve this, the test uses the complementary error function (Erfc) in- Matlab or Java. The
following steps are involved.

1. Generate m PRN and concatenate them into a string of bits.


Let the length of this string be n. the 0’s are first converted into -1’s & then the obtained set of -
1 and 1 values are all added up . let Sn= X1 +X2 +…..Xn
2. Compute the test statistic Sobs= │S│/sqrt(n)
3. Compute the P- value = Erfc (Sobs/sqrt(n)
If P- Value <0.01, then we decide to reject the null hypothesis.
It is recommended that the sequence of a few thousand bits is tested.

Example
Consider 1011010101
Then Sn= 1-1+1+1-1+1-1+1-1+1= 2
Sobs =2/sqrt(10) = 0.6324
For α= 0.01, we obtain that P- value = Erfc (0.6324)= 0.5271> 0.01. thus the sequence is
accepted as being random.

ii) Serial test


Given that numbers in the sequence should be independent, a good random number generator
should produce pairs of numbers that uniformly distributed.
There are 2k different ways of combining k- bits. Each of these combination has the same chance
of occurring, if the sequence of the k- bits is random.

The serial test determines whether the number of times each of this combination occurs is
uniformly distributed.

iii) Runs Tests

The runs test examines the arrangement of numbers in a sequence to test the hypothesis of
independence.
A run is defined as a succession of similar events preceded and followed by a different event.
E.g. in a sequence of tosses of a coin, we may have

13
HTTHHTTTHT
The first toss is preceded and the last toss is followed by a "no event". This sequence has six
runs, first with a length of one, second and third with length two, fourth length three, fifth and
sixth length one.
A few features of a run:
 two characteristics: number of runs and the length of run
 an up run is a sequence of numbers each of which is succeeded by a larger number; a
down run is a sequence of numbers each of which is succeeded by a smaller number
If a sequence of numbers have too few runs, it is unlikely a real random sequence. E.g. 0.08,
0.18, 0.23, 0.36, 0.42, 0.55, 0.63, 0.72, 0.89, 0.91, the sequence has one run, an up run. It is not
likely a random sequence.
If a sequence of numbers have too many runs, it is unlikely a real random sequence. E.g. 0.08,
0.93, 0.15, 0.96, 0.26, 0.84, 0.28, 0.79, 0.36, 0.57. It has nine runs, five up and four down. It is
not likely a random sequence

For example, in the stock market, run test of randomness is applied to know if the stock price of
a particular company is behaving randomly, or if there is any pattern.

iv) Gap Test


The gap test is used to determine the significance of the interval between recurrences of the same
digit. Typically, a gap is the distance between an item and its next recurrence.
A gap of length x occurs between the recurrence of some digit.

v) Tests for Auto-correlation


The tests for auto-correlation are concerned with the dependence between numbers in a
sequence.
The test computes the auto-correlation between every m numbers (m is also known as the lag)
starting with the ith number.

Autocorrelation means that the data has correlation with its lagged value. Hence this method is
used to test whether or not the data has correlation with the lagged value.

vi)Poker Test
The poker test for independence is based on the frequency in which certain digits are repeated in
a series of numbers.
14
This considers groups of k members of the sequence and count the number of distinct values
represented in each group (e.g., a hand of 5 cards falls into one of a number of groups, such as
one pair, two pairs, three of a kind, etc)
For example 0.255, 0.577, 0.331, 0.414, 0.828, 0.909, 0.303, 0.001... In each case, a pair of like
digits appears in the number.

4.10 Generating Random Variates


Random numbers following a specific distribution are called random variates or stochastic
variates. A simulation that has any random aspects must involve generating random variates
from probability distributions. A random variate is a variable generated from uniformly
distributed pseudorandom numbers. The term ‘generating random variates’ refers to the activity
of obtaining an observation on (or realization of) a random variable from the derived
distribution.
These distributions are specified as a result of fitting some appropriate distributional form e.g.
exponential, gamma or Poisson to observed data.

The basic ingredient needed for every method of generating random variates from any
distribution or random process is a source of Independent and identically distributed (IID) or
uniform distribution 𝑈(0,1) random numbers. There are several alternative algorithms for
generating random variates from a given distribution.

Factors to Consider when selecting RV Algorithm


The following factors are important when choosing which algorithm to use in a particular
simulation study:
i. Exactness: The algorithm should result in random variates with exactly the desired
distribution within the unavoidable external limitations of machine accuracy and
exactness of the 𝑈(0,1) random number generator.
ii. Efficiency: The algorithm should be efficient in terms of both storage space and
execution time. Some algorithms require storage of large number of constants or large
tables. The execution time has two factors:
-Marginal execution time: generation of each random variable is done in a short time.
-Setup time: any initial computing required on particular distribution parameters.
iii. Overall complexity: These include conceptual as well as implementation factors. The
potential gain in efficiency that might be experienced by using a more complicated

15
algorithm should be carefully weighed against the extra effort needed to understand and
implement it.
iv. Robustness: Some algorithms rely on a source of random variables from distributions
other that 𝑈(0,1). Also a given algorithm may be efficient for some parameter values but
costly for others. A good algorithm should be efficient for a wide range of parameter
values (robust).
v. Ability to use variance-reduction techniques: Two commonly used techniques are:
-Common random variables
-Antithetic variates (contrast to common)

These techniques require synchronization of the basic 𝑈(0,1) input random variates used in the
simulation of the system under study. This synchronization is more easily accomplished for
certain types of random variate generation algorithms. In particular, the universe transform
method can be very helpful in facilitating the desired synchronization and variance reduction.

Techniques/Algorithms for Generating Random Variates


There are many techniques for generating random variate namely:
i) Direct method
ii) Inverse transform method
iii) Acceptance-Rejection method

i) Direct method
Directly uses the definition of the distribution. We have inbuilt functions that directly generate
the desired random number.
e.g rand: generates uniform random variate on (0,1)
randn; generate random numbers from standard normal distribution
binornd: generate random numbers from binomial distribution e.t.c

To generate random numbers between interval say (a,b) different from (0,1) say (3,8) we have
x= floor (rand (1,8)* 5+3)
in general we have x= floor (rand (1,y)* (b-a)+a)

ii) The inverse transform method

16
The method is applicable only to cases where the cumulative density function (cdf) can be
inversed analytically.
Assume that we wish to generate stochastic variates from a probability density function (pdf) f
(x).
Let F(x) be its cumulative density function. We note that F(x) is defined in the region (0,1)
We explore this property of the cumulative density function to obtain the following simple
stochastic variants generator.
First generate a random number r which we set equal to F(x) . F(x)=r
The quantity x is then obtained by inverting F. i.e x= F-1(r)

Example
We wish to generate random variates with pd of f(x)= 2x . 0≤x≤1
First calculate the cdf F(x) i.e
F(x) =
Let r be a random number , we have
r=x2
x=√r

iii) The Acceptance-rejection method


The Acceptance-rejection method can be used to generate random variates, if F (x) is bounded
and x has a finite range, say a ≤ x ≤b, the following steps are involved:

1. Normalize the range of F (x) by a scale factor C so that C F (x) ≤ 1, a ≤x≤b.


2. Define x as a linear fxn of r,1.e x= a + (b-a)r where r is a random number.
3. Generate pairs of random number (r1,r2 )
4. Accept the pair and use x= a+(b-a) r 1 as a random variate whenever the pair satisfies the
relationship r2≤ cf(a+(b-a)r1) i.e the pair (x1r2) falls under the curve below.
Example
Use the rejection method to generate random variates with probability density fxn f(x) = 2x 0≤
x≤1.
This is accomplished using the following procedure.
 Select c such that (f(x)<1 i.e c=1/2
 Generate r1, and set x= r1
 Generate r2. If r2< cf(r1) =(1/2)*2 r1= r1, then accept r2, otherwise go back to the previous
step.
17
4.11 Parameter Estimation
Estimate model parameters
Parameter estimation refers to the process of using sample data (in reliability engineering,
usually times-to-failure or success data) to estimate the parameters of the selected
distribution. Several parameter estimation methods are available.
Parameter estimation plays a critical role in accurately describing system behavior through
mathematical models such as statistical probability distribution functions, parametric dynamic
models, and data-based Simulink models.

Improving the accuracy of statistical models can involve estimating:


 Parameters of a probability distribution, such as the mean and standard deviation of a
normal distribution
 Regression coefficients of a regression model, such as y = a'x
 Creating accurate parametric dynamic models can involve estimating:

18

You might also like