0% found this document useful (0 votes)
36 views1 page

For If If End End End: %PDF of Uniform Random Variable

The document contains code to generate and plot the probability density functions (PDFs) of uniform and Gaussian random variables. It also contains code to calculate and display common descriptive statistics - mean, variance, skewness, and kurtosis - for sample data using both custom functions and built-in MATLAB functions.

Uploaded by

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

For If If End End End: %PDF of Uniform Random Variable

The document contains code to generate and plot the probability density functions (PDFs) of uniform and Gaussian random variables. It also contains code to calculate and display common descriptive statistics - mean, variance, skewness, and kurtosis - for sample data using both custom functions and built-in MATLAB functions.

Uploaded by

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

%PDF of Uniform Random Variable

clear all;clc;
n1=input('Enter lower limit');
n2=input('Enter upper limit');
n=-2*n1:0.01:3*n2;
u=zeros(1,length(n));
for i=1:length(n)
if(n(i)>=n1)
if(n(i)<=n2)
u(i)=1/(n2-n1);
end
end
end
plot(n,u,'r.-');
title('PDF of Uniform Random Variable');
%PDF of Gaussian Random Variable
clear all;clc;
low=input('Enter lower limit');
high=input('Enter upper limit');
inc=input('Enter the increment value');
x=low:inc:high;
x1=length(x);
meanx=sum(x)/x1;
varx=zeros(1,100);
for i=1:x1
y(i)=(x(i)-meanx)^2;
end
var=sum(y(i))/x1;
Gaussian=1/sqrt(2*pi*varx).*exp(-(x-meanx).^2)./(2*varx);
plot(Gaussian,'b.-');grid;
title('PDF of Gaussian Random Variable');
%mean variance meansquare skewness kurtosis
clear all;
clc;
x=[1 2 3 4 5 6];
n=length(x);
m=sum(x)/n;
disp('mean=');disp(m);
v=sum((x-m).^2)/n;
disp('variance=');disp(v);
ms=v+m^2;
disp('mean square=');disp(ms);
s=sum((x-m).^3)/n;
sn=s/sqrt(v);
disp('skewness=');disp(sn);
k=sum((x-m).^4)/n;
kt=k/v^2;
disp('kurtosis=');disp(kt);
disp('verification using built in functions');
disp('mean=');disp(mean(x));
disp('variance=');disp(moment(x,2));
disp('mean square=');disp(mean(x)^2+moment(x,2));
disp('skewness=');disp(moment(x,3)/sqrt(moment(x,2)));
disp('kurtosis=');disp(moment(x,4)/moment(x,2));

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy