Professional Documents
Culture Documents
1 Project 3
1 Project 3
Exponential
Code:
% pdf of exponential
R=rand(1,2000); %R represents the uniform random variable
X=-6*log(R); %X represents the exponential random variable with mean 6
M=mean(X) %Calculate mean of the random variable
Var=cov(X) %Calculate variance of the random variable
[p,q]=hist(X,50); %pdf of the exponential random variable
bar(q,p/2000);
xlabel('X');
ylabel('Probability Density Function');
Mean = 6.0099
Variance = 37.6312
2.Bernoulli
Code:
% pdf of Bernoulli
P = 0.4
n = 2000
A = randn(n, 1)
X = sum(A < p)
hist(X)
xlabel('X');
ylabel('Probability Density Function');
Sittipong Ruangsang
G 01177205
ECE 528
Bijan Jabbari