www.gusucode.com > stats 源码程序 matlab案例代码 > stats/ComputeGeometricDistributionCdfExample.m
%% Compute Geometric Distribution cdf % % Copyright 2015 The MathWorks, Inc. %% % Suppose you toss a fair coin repeatedly, and a "success" occurs when the % coin lands with heads facing up. What is the probability of observing % three or fewer tails ("failures") before tossing a heads? %% % To solve, determine the value of the cumulative distribution function % (cdf) for the geometric distribution at _x_ equal to 3. The probability of % success (tossing a heads) _p_ in any given trial is 0.5. x = 3; p = 0.5; y = geocdf(x,p) %% % The returned value of _y_ indicates that the probability of observing three % or fewer tails before tossing a heads is 0.9375.