Sei sulla pagina 1di 14

1

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
2
- 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
3
1. Introduction :
MATLABis 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.
Algorithmdevelopment.
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.
4
2. Definitions
- Random Variable Concept ?
RandomVariable (r.v): Afinite single valued function X( ) that maps the set of all
experimental outcomes O into the set of real numbers Ris said to be a r.v, if the set
{ | X ( )
s 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}
= function of 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.
5
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) ?
The derivative of CDFis known as probability density function (PDF) and it is denoted
as f(x). Mathematically:
( ) =
( )
Probability Density Function PDF
Equivalently
F(x) =
( )

< <
This is for continuous variables,
but in case of discrete random variables PDFis 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 PDFis ( ) .
6
- Mean or Expected value of X:
This is first moment of the random variable X. E() denotes expectation (statistical averaging)
E(x) =mx=
( )

< <
The n-th moment is defined as
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) )= ( mx) ( )

- Variance ?
when n =2 the central moment is called the variance of the random variable and denoted as
= ( mx) ( )

variance provides the measure of the dispersion of the random variable X.


= ( ) - mx
- Joint moment ?
in case of two random variables X1 and X2 with joint PDFf(x1,x2) we define joint moment as:
E( ) =
( , )

- joint central moment as:


E( mx) ( mx) ) = ( m1) ( mx) ( , )

- Correlation ?
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
E =
( , )

- Covariance ? of X
i
and X
j
is
= E - mi mj
7
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 :
8
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;
- Common PDFs command
- Uniformpdf .m:
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
-1 0 1 2 3 4 5 6 7
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
G
a
u
s
s
i
a
n
p
d
f
mean=3, sigma=1
9
- Normalpdf.m :
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;
-10 -8 -6 -4 -2 0 2 4 6 8 10
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
u
n
i
f
o
r
m
p
d
f
-15 -10 -5 0 5 10 15 20 25
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.1
n
o
r
m
a
p
d
f
mean=3, sigma=3
10
- Normal and Uniform PDFs (joint)
- randPdf.m
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');
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
500
1000
1500
Uniform distribution, histogram
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
50
100
150
Uniform distribution, 100 bin histogram
11
- 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');
- randnPdf.m:
Function randn generates normally distributed random values with mean=0 and standard
deviation=0.
%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');
100 101 102 103 104 105 106 107 108 109 110
0
20
40
60
80
100
120
Uniform distribution Shifted and Scaled, 100 bin histogram
12
- 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');
-4 -3 -2 -1 0 1 2 3 4 5
0
1000
2000
3000
Normal distribution, histogram
-4 -3 -2 -1 0 1 2 3 4 5
0
100
200
300
400
Normal distribution, 100 bin histogram
-20 -10 0 10 20 30 40
0
1000
2000
3000
Normal distribution with Mean=5, Std=7
-20 -10 0 10 20 30 40
0
100
200
300
400
Normal distribution with Mean=5, Std=7
13
5. Acceptable strings for name (specified in single quotes) ::
Name
Distribution
Input
Parameter A
Input
Parameter B
Input
Paramet
er c
'beta' or 'Beta' Beta Distribution A B
'bino' or'Binomial' Binomial Distribution
n: number of
trials
p: probability
of success for
each trial

'birnbaumsaunders'
Birnbaum-Saunders
Distribution

'burr' or 'Burr' Burr Type XII Distribution
: scale
parameter
c: shape
parameter
k: shape
parameter
'chi2' or'Chisquare' Chi-Square Distribution
: degrees of
freedom

'exp' or'Exponential' Exponential Distribution : mean
'ev' or 'Extreme Value' Extreme Value Distribution
: location
parameter
: scale
parameter

'f' or 'F' F Distribution
1: numerator
degrees of
freedom
2:
denominator
degrees of
freedom

'gam' or 'Gamma' Gamma Distribution
a: shape
parameter
b: scale
parameter

'gev' or'Generalized
Extreme Value'
Generalized Extreme Value
Distribution
k: shape
parameter
: scale
parameter
: location
parameter
'gp' or'Generalized
Pareto'
Generalized Pareto
Distribution
k: tail index
(shape)
parameter
: scale
parameter
:
threshold
(location)
parameter
'geo' or'Geometric' Geometric Distribution
p: probability
parameter

'hyge' or'Hypergeomet
ric'
Hypergeometric
Distribution
M: size of the
population
K: number of
items with the
desired
characteristic
in the
population
n: number
of samples
drawn
'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
successes
p: probability
of success in a
single trial

14
'ncf' or'Noncentral F' Noncentral F Distribution
1: numerator
degrees of
freedom
2:
denominator
degrees of
freedom
:
noncentrali
ty
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
'rayl' or'Rayleigh' Rayleigh Distribution
b: scale
parameter

'rician' Rician Distribution
s:
noncentrality
parameter
: scale
parameter

't' or 'T' Student's t Distribution
: degrees of
freedom

'tlocationscale'
t Location-Scale
Distribution
: location
parameter
: scale
parameter
: shape
parameter
'unif' or 'Uniform'
Uniform Distribution
(Continuous)
a: lower
endpoint
(minimum)
b: upper
endpoint
(maximum)

'unid' or 'Discrete
Uniform'
Uniform Distribution
(Discrete)
N: maximum
observable
value

'wbl' or 'Weibull' Weibull Distribution
a: scale
parameter
b: shape
parameter

Potrebbero piacerti anche