Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Models for Random Processes-Mathematical Modeling and Simulation-Lecture Slides, Slides of Mathematical Modeling and Simulation

These lecture slides are delivered at The LNM Institute of Information Technology by Dr. Sham Thakur for subject of Mathematical Modeling and Simulation. Its main points are: Models, Random, Processes, Classification, Pseudorandom, Numbers, Linear, Congruential, Generators, Sequence

Typology: Slides

2011/2012

Uploaded on 07/03/2012

jaee
jaee 🇮🇳

4.7

(22)

101 documents

1 / 27

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture Slides
on
Modeling and Simulation
Lecture: Models for Random Processes
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download Models for Random Processes-Mathematical Modeling and Simulation-Lecture Slides and more Slides Mathematical Modeling and Simulation in PDF only on Docsity!

Lecture Slides

on

Modeling and Simulation

Lecture: Models for Random Processes

Classification of random numbers

Random numbers for use in computer programs

can be classified into different categories:

Truly random numbers: Obviously these cannot be

produced by computer programs, They must be

supplied by an external source.

Such sequences are available (e.g. in tabular

forms), but clumsy to use and often not sufficient

in terms of speed and number.

Random Numbers

  • Well-known techniques for generating random

numbers are deterministic.

  • The number sequences is mostly indistinguishable from

true random sequences.

  • The deterministic nature provides their reproducibility

in computations.

  • All computers invariably use pseudo-random numbers

generated by a deterministic process.

  • Then statistical methods are used to validate random

sequences.

Methods for generating a sequence of random numbers have

been extensively studied and are well understood.

 A function called a generator is defined that, when

applied to a number, it gives the next number in the

sequence.

 For example, the linear congruential generators

considered here have the following general form:

Random Numbers

One Typical Generator is

Xk+1 = ( a Xk + c ) mod m

Where X k is the kth element, and X o, a, c & m define the generator

For numbers in the range [0, 1] we divide by m.

Example 1: Model a system Using Random Numbers

Consider a basket having 5 red balls and total 20 balls.

Pick a ball without looking and will it be a red?

Call this as an event A. The event A has probability p and the

probability of not happening of A is 1 – p. Clearly the outcome B has

the probability 1 – p.

The computer will simulate this experiment by generating a random

number  in the interval [0, 1] and we will call the event A has

occurred if the value of  is 0   p

and the event B will occur if p  ^1

p 1 - p

p 1

Example 1: Model a system Using Random Numbers

The computer will

simulate this

experiment by

generating a random

number  in the

interval [0, 1] and

we will call the event

A has occurred if the

value of  is less

than p.

Here p = 5/20=0.

Random Number

Event A Event B

0.112 YES
0.523 YES
0.477 YES
0.011 YES
0.918 YES
0.669 YES
0.756 YES
0.312 YES
0.278 YES

Program in MATLAB

N_parent = 1000; N_daughter = 0; tmax = 200; probability_of_decay = 0.01; rand('state', 0) % initialize the generator to state zero t = 0; for i = 1: tmax xt(i) = t; xx(i) = N_parent; yy(i) = N_daughter; M = N_parent; for k = 1: M x = rand; if x < probability_of_decay N_parent = N_parent - 1; N_daughter = N_daughter + 1; end end t = t + 1 end plot(xt, xx, 'LineWidth',2) hold on plot(xt, yy, 'LineWidth',2) axis([0 tmax 0 1200]) xlabel('time, t') ylabel('Number ') Grid hold off

t N( t) N(o) e

  •  

where,  is a constant related to the probability of decay per second for the parent nucleus.

This graph for the decay is similar to an exponential function’s behavior

and we may attempt to fit the following:

Program in MATLAB

Uniform Random Numbers

Here is program to generate random numbers and then plot them in 2D figure.

N = 20 ;

rand('state', 0) % initial state nframes = 100 ; % number of frames for movie for j = 1: nframes j axis([-1.2 1.2 -1.2 1.2]) hold on for k = 1: N x = 1.0 - 2.rand; y = 1.0 - 2.rand;

plot(x, y, 'b:.') hold on

end m(k)= getframe; end

Uniform Random Numbers

Here random numbers are generted and plotted and you can see they are everywhere in this figure. That is no preferred place.

We must keep in view that the random number generator will provide the same

sequence of numbers again if it was initiated by the same number called ‘state’

or ‘seed’. If the seed is random or generated from a calendar/clock circuit of

the computer then the sequence will be different.

Random Distributions

MATLAB provides randn

function for Gaussian

distribution based random

numbers and arrays. Its general

synopsis is Y = randn(m,n)

and it will return m × n matix of

random entries with average

zero and variance equal to one.

Let us demonstrate use of uniform distribution of random numbers,

to generate a Gaussian or a Normal distribution. The algorithm to

generate a Gaussian distribution of N random numbers is given next.

The randn by itself returns a scalar value when called. Its state can be set by

randn(‘state’,j) command.

-3 -2 -1 0 1 2 3

0.

0.

0.

0.

0.

0.

0.

Deviation

h(z)^ Mean Value

The value of z

Random Distributions

Figure: The Gaussian distribution obtained from MATLAB

Normal Random Distributions

Normal Random Distributions

% Program to generate 20 bins of a normal distributed

Max_bins = 20;

randn('state', 0) % initialize the generator to state zero

y = randn(90000,1);

n = hist(y, Max_bins) % converts the data from y into 20 bins

bar(n) % plots the data as a bar graph