Geometric CDF
p = distfun_geocdf(X,Pr) p = distfun_geocdf(X,Pr,lowertail)
a 1x1 or nxm matrix of doubles, the number of Bernoulli trials after which first success occurs . X belongs to the set {0,1,2,3,......}
a 1x1 or nxm matrix of doubles, the probability of success in a Bernoulli trial
a 1x1 matrix of booleans, the tail (default lowertail=%t). If lowertail is true (the default), then considers P(X<x) otherwise P(X>x).
a nxm matrix of doubles, the probability.
Computes the cumulative 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.
//Test with X scalar, Pr scalar p = distfun_geocdf(3,0.5) expected = 0.9375; //Test with X expanded, Pr scalar computed = distfun_geocdf([2 3],0.33) expected = [0.699237 0.7984888]; //Test with X scalar, Pr expanded computed = distfun_geocdf(3,[0.2 0.4]) expected = [0.5904 0.8704]; //Test with both the arguments expanded computed = distfun_geocdf([3 4 8],[0.5 0.8 0.2]) expected = [0.9375 0.99968 0.8657823]; //Plot the function scf(); Pr = 0.2; Pr1 = 0.5; Pr2 = 0.8; for i=0:10 X = linspace(i,i+1,20); y = distfun_geocdf(i,Pr); plot(X,y,'r'); y = distfun_geocdf(i,Pr1); plot(X,y,'g'); y = distfun_geocdf(i,Pr2); plot(X,y,'b'); end xtitle("Geometric CDF","x","P(X<x)"); legend(["Pr=0.2","Pr=0.5","Pr=0.8"]); // See upper tail p = distfun_geocdf(3,0.1) lt_expected = 0.3439; q = distfun_geocdf(3,0.1,%f) ut_expected = 0.6561; p+q // See accuray in the upper tail p = distfun_geocdf(100,0.5,%f) expected = 3.944305e-31 | ![]() | ![]() |
http://en.wikipedia.org/wiki/Geometric_distribution