<< Tutorial Tutorial Beta >>

Distfun >> Distfun > Tutorial > Distribution Function Plots

Distribution Function Plots

A collection of distribution function plots.

Purpose

The goal of this document is to show pdf and cdf plots for different distribution functions of the distfun toolbox.

Geometric distribution

Reference: Geometric distribution. In Wikipedia, The Free Encyclopedia. Retrieved 13:45, August 09, 2012, from http://en.wikipedia.org/wiki/Geometric_distribution

To make pdf plot, we can use the distfun_geopdf function.

scf();
x = 0:10;
y = distfun_geopdf(x,0.2);
plot(x,y,"ro-");
y1 = distfun_geopdf(x,0.5);
plot(x,y1,"go-");
y2 = distfun_geopdf(x,0.8);
plot(x,y2,"bo-");
xtitle("Geometric PDF","x","P(x=x)");
legend(["pr=0.2","pr=0.5","pr=0.8"]);

The previous script produces the following output.

To make cdf plot, we can use the distfun_geocdf function.

x=(0:11)';
scf(); 
p1=distfun_geocdf(x,0.2);
p2=distfun_geocdf(x,0.5);
p3=distfun_geocdf(x,0.8);
distfun_plotintcdf(x,[p1,p2,p3],["r" "b" "g"],..
    ["pr=0.2" "pr=0.5" "pr=0.8"]);
xtitle("Geometric CDF")

The previous script produces the following output.

Binomial distribution

Reference: Binomial distribution. In Wikipedia, The Free Encyclopedia. Retrieved 14:54, August 10, 2012, from http://en.wikipedia.org/wiki/Binomial_distribution

To make pdf plot, we can use the distfun_binopdf function.

scf();
N1 = 20;
x = 0:N1;
y1 = distfun_binopdf(x,N1,0.5);
plot(x,y1,"bo-")
N2 = 20;
x = 0:N2;
y2 = distfun_binopdf(x,N2,0.7);
plot(x,y2,"go-")
N3 = 40;
x = 0:N3
y3 = distfun_binopdf(x,N3,0.5);
plot(x,y3,"ro-")
legend(["pr=0.5, N=20","pr=0.7, N=20","pr=0.5, N=40"]);
xtitle("Binomial PDF","x","P(x)")

To make cdf plot, we can use the distfun_binocdf function.

scf();
x = (0:20)';
p1=distfun_binocdf(x,20,0.5);
p2=distfun_binocdf(x,20,0.7);
p3=distfun_binocdf(x,40,0.5);
legendspec=["pr=0.5, N=20","pr=0.7, N=20","pr=0.5, N=40"];
distfun_plotintcdf(x,[p1,p2,p3],["b" "g" "r"],legendspec);
xtitle("Binomial CDF")

Chi-Square distribution

Reference: Chi-Square distribution. In Wikipedia, The Free Encyclopedia. Retrieved 15:16, August 10, 2012, from http://en.wikipedia.org/wiki/Chisquare_distribution

To make pdf plot, we can use the distfun_chi2pdf function.

h=scf();
k = [2 3 4 6 9 12];
cols = [1 2 3 4 5 6];
lgd = [];
for i = 1:size(k,'c')
   x = linspace(0,10,1000);
   y = distfun_chi2pdf ( x , k(i) );
   plot(x,y)
   str = msprintf("k=%s",string(k(i)));
   lgd($+1) = str;
end
for i = 1:size(k,'c')
    hcc = h.children.children;
    hcc.children(size(k,'c') - i + 1).foreground = cols(i);
end
xtitle("Chi-square PDF","x","f(x)")
legend(lgd);

To make cdf plot, we can use the distfun_chi2cdf function.

h=scf();
k = [2 3 4 6 9 12];
cols = [1 2 3 4 5 6];
lgd = [];
for i = 1:size(k,'c')
  x = linspace(0,10,1000);
  y = distfun_chi2cdf ( x , k(i) );
  plot(x,y)
  str = msprintf("k=%s",string(k(i)));
  lgd($+1) = str;
end
for i = 1:size(k,'c')
    hcc = h.children.children;
    hcc.children(size(k,'c') - i + 1).foreground = cols(i);
end
xtitle("Chi-square CDF","x","f(x)")
legend(lgd);

Poisson distribution

Reference: Poisson distribution. In Wikipedia, The Free Encyclopedia. Retrieved 15:16, August 10, 2012, from http://en.wikipedia.org/wiki/Poisson_distribution

To make pdf plot, we can use the distfun_poisspdf function.

scf();
x = 0:20;
y = distfun_poisspdf(x,1);
plot(x,y,"ro-");
y1 = distfun_poisspdf(x,4);
plot(x,y1,"go-");
y2 = distfun_poisspdf(x,10);
plot(x,y2,"bo-");
xtitle("Poisson PDF","x","P(X=x)");
legend(["lambda=1","lambda=4","lambda=10"]);

To make cdf plot, we can use the distfun_poisscdf function.

h=scf();
x=(0:20)';
p1=distfun_poisscdf(x,1);
p2=distfun_poisscdf(x,4);
p3=distfun_poisscdf(x,10);
legendspec=["lambda=1","lambda=4","lambda=10"];
distfun_plotintcdf(x,[p1,p2,p3],["r" "g" "b"],legendspec);
xtitle("Poisson CDF")
h.children.children(1).legend_location="in_lower_right";


Report an issue
<< Tutorial Tutorial Beta >>