Geometric PDF
y = distfun_geopdf(x,pr)
a matrix of doubles, the number of Bernoulli trials after which the first success occurs. x belongs to the set {0,1,2,3,.....}
a matrix of doubles, the probability of success in a Bernoulli trial. pr in (0,1].
a matrix of doubles, the probability density.
Computes the probability distribution function of the Geometric distribution function.
Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.
The function definition is:
Analysis of the random variable
The random variable X is the number of Bernoulli trials needed to get one success.
Compatibility Note : x belongs to the set {0,1,2,3,...}. This choice is compatible with Matlab and R. This is different from Scilab v5 grand(m,n,"geom"), which uses {1,2,3,...}.
// Test x scalar , pr scalar computed = distfun_geopdf(3,0.5) expected = 0.0625; // Test with x expanded, with pr scalar computed = distfun_geopdf([2 3],0.1) expected = [0.081 0.0729]; //Test with x scalar, pr expanded computed = distfun_geopdf(3,[0.2 0.4]) expected = [0.1024 0.0864]; //Test with both arguments expanded computed = distfun_geopdf([3 4 8],[0.5 0.8 0.2]) expected = [0.0625 0.00128 0.033554432]; // Plot the 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"]); | ![]() | ![]() |
http://en.wikipedia.org/wiki/Geometric_distribution