Sei sulla pagina 1di 14 Yarmouk University

Hijjawii faculty for engineering Technology

Communication Engineering Department

&

Prince Fasial Information Technology center

RANDOM PROJECT

CME 610

Dr. Khaled Gharaibeh

Prensented By : Eng. Omar S. Abu_Rumman

2012976008

 Table of contents 1. Introduction 3 2. Definitions 4 3. General Information .5 4. Analysis Using Matlab & Result 7 5. Acceptable Strings For Name 13

1. Introduction :

MATLAB is a high-performance language for technical computing. It integrates

computation, visualization, and programmingin an easy-to-use environment where

problems and solutions are expressed in familiar mathematical notation. MATLAB is an

interactive system whose basic data element is an array that does not require

dimensioning. MATLAB stands for MATrix LABoratory.

Typical uses include:

Math and computation. Algorithm development. Data acquisition. Modeling, simulation, and prototyping. Data analysis, exploration, and visualization. Scientific and engineering graphics. Application development, including graphical user interface building.

And you will be using Matlab to solve problems in many application :

Circuits Communication systems Digital signal processing Control systems Probability and statistics

Why Use Computer Simulation?

A computer simulation is valuable in many respects. It can be used

a. to provide counterexamples to proposed theorems

b.to build intuition by experimenting with random numbers

c. to lend evidence to a conjecture.

2. Definitions

Random Variable Concept ?

Random Variable (r.v): A finite single

experimental outcomes into the set of real numbers R is said to be a r.v, if the set | X ( )

valued function X( ) that maps the set of all

x is an event ( F ) for every x in R. Or is numerically valued function X of with domain . where : X ( ) is called a r.v. on . A real r.v. is a real function of the elements of a sample space S .

Distribution Function (CDF) ?

Cumulative probability distribution function (CPDF) defined as

 P {X x} = probability of the event {X x} = F X (x) with ( x )

So for a given random variable X, let us consider the event {X x} where x is any real number in

the interval (- , ). We write the probability of this event as P(X x) and denote it simply by F(x), i.e.

F(x) = P(X x)

- < x <

Function F(x) is called Probability Distribution Function, also known as Cumulative

Distribution Function (CDF).

In Matlab

 Y = cdf('name',X,A) Y = cdf('name',X,A,B) Y = cdf('name',X,A,B,C)

Description:

Y = cdf('name',X,A) computes the cumulative distribution function for the one-parameter family of distributions specified by name. A contains parameter values for the distribution. The cumulative distribution function is evaluated at the values in X and its values are returned

 in Y. If X and A are arrays, they must be the same size. If X is a scalar, it is expanded to a constant

matrix the same size as A. If A is a scalar, it is expanded to a constant matrix the same size

 as X. Y is the common size of X and A after any necessary scalar expansion.

Y = cdf('name',X,A,B) computes the cumulative distribution function for two-parameter families of distributions, where parameter values are given in A and B.

If X, A, and B are arrays, they must be the same size. If X is a scalar, it is expanded to a

constant matrix the same size as A and B. If either A or B are scalars, they are expanded to constant matrices the same size as X.

Y is the common size of X, A, and B after any necessary scalar expansion.

Y = cdf('name',X,A,B,C) computes the cumulative distribution function for three-parameter families of distributions, where parameter values are given in A, B, and C.

If X, A, B, and C are arrays, they must be the same size. If X is a scalar, it is expanded to a

constant matrix the same size as A, B, and C. If any of A, B or C are scalars, they are expanded to constant matrices the same size as X.

Y is the common size of X, A, B, and C after any necessary scalar expansion.

Probability Density Function (PDF) ?

()= () (

F(x) =

()=

The derivative of CDF is known as probability density function (PDF) and it is denoted

as f(x). Mathematically: ) < <

Probability Density Function PDF

Equivalently

This is for continuous variables, but in case of discrete random variables PDF is expressed as )

( = )(

3. General Information

Statistical Averages of Random variables: The first and second moments of a single random variable and the joint moments such are correlation and covariance between any pair of random variables in a multidimensional set of random variables are of particular interests. For all the cases below: X is single random variable and its PDF is ( ) .

Mean or Expected value of X: ( This is first moment of the random variable X. E() denotes expectation (statistical averaging)

The n-th moment is defined as (

E(x) =mx=

E( < <

) =mx= If mx is the mean value of the random variable X, the nth central moment is defined as

E(Y)=E((X- mx) )= = ∫
= (

Variance ?

( − m x)

mx) ( )

when n = 2 the central moment is called the variance of the random variable and denoted as (
) variance provides the measure of the dispersion of the random variable X.

) - mx

Joint moment ? ∝ (
,
)
− m x ) ) =
∝ (

in case of two random variables X1 and X2 with joint PDF f(x1,x2) we define joint moment as:

E(

E (

) =∬ − m 1) (
(
,
)
− m x)

joint central moment as:

m x ) (

Correlation ? E =
∝ (
= E
- mi mj ,
)

when k = n = 1, we get correlation and covariance of the random variables X 1 and X 2 i.e. Correlation between X i and X j is given by joint moment

Covariance ? of X i and X j is

the n x n matrix with the elements µ ij is called the covariance matrix of the random variables

X i

, i = 1,2,

n

The two random variables are said to be uncorrelated if

E(X i X j ) = E(X i )E(X j ) = m i m j

which means µ ij =0.

i.e. X i and X j are statistically independent then they are uncorrelated but vice versa is not true.

Two random variables are said to be orthogonal is

E(X i X j ) = 0

this condition holds when X i and X j are uncorrelated and either one or both of the random variables have zero mean

The equivalent Matlab functions for above : 4. Analysis Using Matlab & Result : Note: please press ctrl+click on m file to open it

(Gauusian.m) %plot Gaussian density function,mean=3,stdev(sigma)=1 ax=3; sigma=1; %range for x from -3 to +3

x=-1:0.1:7;

c=1/sqrt(2*pi*sigma^2);

y=c*exp((-(x-ax).^2)/(2*sigma^2))

plot(x,y); ylabel('Gaussian pdf'); xlabel('mean=3, sigma=1'); grid; 0.4
0.35
0.3
0.25
f
d
p
n
0.2
i a
s
s
u
a
G 0.15
0.1
0.05
0
-1
0
1
2
3
4
5
6
7

Uniformpdf .m :

mean=3, sigma=1

Common PDFs command

Uniform probability density functions can be generated using Function unifpdf ,Given a range x, and a left and right endpoint, unifpdf distributes probabilities uniformly over x. %plot a uniform density function, %range for x from -10 to +10%

a=-7;

b=7;

x=-10:1:10;

pdfuniform = unifpdf(x,a,b) plot(x,pdfuniform); ylabel('uniform pdf');grid

f

d

p

m

r

i o

f

n

u

Normalpdf.m : 0.08
0.07
0.06
0.05
0.04
0.03
0.02
0.01
0
-10
-8
-6
-4
-2
0
2
4
6
8
10

Normal probability density functions are generated using function normpdf. Characteristic of a normal distribution are mean and standard deviation.

%plot Normal Density function,normpdf(x,mean,std) %range for x from -15 to +25 (vector range )

x=-15:0.1:25;

mean=3;

sigma=4;

pdfnormal=normpdf(x,mean,sigma); plot(x,pdfnormal); ylabel('norma pdf'); xlabel('mean=3, sigma=3'); grid;

f

d

p

a

m

r

o

n 0.1
0.09
0.08
0.07
0.06
0.05
0.04
0.03
0.02
0.01
0
-15
-10
-5
0
5
10
15
20
25

mean=3, sigma=3

randPdf.m

Normal and Uniform PDFs (joint)

unifpdf and normpdf generate "perfect" densities; however, typical data observations only fit these distributions approximately. To simulate these situations , Matlab offers functions for random number generation for both uniform and normal distributions.

Function rand generates uniformly distributed random values between 0 and 1.

rand(rows ,columns): matrix with rows and columns of random values.

%plot Normal Density function with uniform ,rand(rows,columns) pdfUniform = rand(1, 10000); subplot(2,1,1), hist(pdfUniform), title('Uniform distribution, histogram'); subplot(2,1,2), hist(pdfUniform, 100), title('Uniform distribution, 100 bin histogram');

Uniform distribution, histogram

 1500 1000 500 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Uniform distribution, 100 bin histogram 150 100 50 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

rand2Pdf.m

To fit a different range of x-values, we can shift and scale the random value matrix accordingly:

%plot Normal Density function with shifting uniform ,rand(rows,columns) pdfUniform = rand(1, 10000); pdfUniformSS = pdfUniform * 10 + 100; hist(pdfUniformSS, 100), title('Uniform distribution Shifted and Scaled, 100 bin histogram');

Uniform distribution Shifted and Scaled, 100 bin histogram 120
100
80
60
40
20
0
100
101
102
103
104
105
106
107
108
109
110

randnPdf.m:

Function

deviation=0.

randn

generates

normally

distributed

random

values

with

mean=0

and

standard

%randn(rows, columns) matrix with rows and columns random values%; pdfNormal = randn(1, 10000); subplot(2,1,1), hist(pdfNormal), title('Normal distribution, histogram'); subplot(2,1,2), hist(pdfNormal, 100), title('Normal distribution, 100 bin histogram'); Normal distribution, histogram
3000
2000
1000
0
-4
-3
-2
-1
0
1
2
3
4
5
Normal distribution, 100 bin histogram
400
300
200
100
0
-4
-3
-2
-1
0
1
2
3
4
5

NormalGuassian.m:

A random normal distribution with mean (mean) and standard deviation (std) is obtained by shifting and scaling:

pdfMean = 5; pdfStd = 7; pdfNormalSS = randn(1, 10000) * pdfStd + pdfMean; subplot(2,1,1), hist(pdfNormalSS), title('Normal distribution with Mean=5, Std=7'); subplot(2,1,2), hist(pdfNormalSS, 100), title('Normal distribution with Mean=5, Std=7');

Normal distribution with Mean=5, Std=7 3000
2000
1000
0
-20
-10
0
10
20
30
40

Normal distribution with Mean=5, Std=7 400
300
200
100
0
-20
-10
0
10
20
30
40

5. Acceptable strings for name (specified in single quotes) :: Input Parameter A Input Parameter B Input Paramet er c Name Distribution 'beta' or 'Beta' Beta Distribution A B n: number of p: probability of success for each trial 'bino' or'Binomial' Binomial Distribution trials Birnbaum-Saunders 'birnbaumsaunders' Distribution 'burr' or 'Burr' Burr Type XII Distribution : scale c: shape k: shape parameter parameter parameter 'chi2' or'Chisquare' Chi-Square Distribution : degrees of freedom 'exp' or'Exponential' Exponential Distribution : mean 'ev' or 'Extreme Value' Extreme Value Distribution : location : scale parameter parameter 2: 1: numerator degrees of freedom denominator 'f' or 'F' F Distribution degrees of freedom 'gam' or 'Gamma' Gamma Distribution a: shape b: scale parameter parameter 'gev' or'Generalized Extreme Value' Generalized Extreme Value Distribution k: shape : scale : location parameter parameter parameter k: tail index (shape) parameter : 'gp' or'Generalized Pareto' Generalized Pareto Distribution : scale threshold parameter (location) parameter 'geo' or'Geometric' Geometric Distribution p: probability parameter K: number of items with the 'hyge' or'Hypergeomet ric' Hypergeometric Distribution M: size of the population desired characteristic in the n: number of samples drawn population 'inversegaussian' Inverse Gaussian Distribution 'logistic' Logistic Distribution 'loglogistic' Loglogistic Distribution 'logn' or'Lognormal' Lognormal Distribution 'nakagami' Nakagami Distribution 'nbin' or 'Negative Binomial' Negative Binomial Distribution r: number of p: probability of success in a single trial successes
 2: : 1: numerator degrees of freedom denominator noncentrali 'ncf' or'Noncentral F' Noncentral F Distribution degrees of ty freedom parameter : 'nct' or'Noncentral t' Noncentral t Distribution : degrees of freedom noncentrality parameter : 'ncx2' or'Noncentral Chi-square' Noncentral Chi-Square Distribution : degrees of freedom noncentrality parameter 'norm' or 'Normal' Normal Distribution : mean : standard deviation 'poiss' or'Poisson' Poisson Distribution : mean b: scale 'rayl' or'Rayleigh' Rayleigh Distribution parameter s: 'rician' Rician Distribution noncentrality : scale parameter parameter 't' or 'T' Student's t Distribution : degrees of freedom 'tlocationscale' t Location-Scale Distribution : location parameter : scale parameter : shape parameter Uniform Distribution (Continuous) a: lower b: upper 'unif' or 'Uniform' endpoint endpoint (minimum) (maximum) N: maximum 'unid' or 'Discrete Uniform' Uniform Distribution (Discrete) observable value 'wbl' or 'Weibull' Weibull Distribution a: scale b: shape parameter parameter