Geometric random numbers
R = distfun_geornd(pr) R = distfun_geornd(pr,[m,n]) R = distfun_geornd(pr,m,n)
a n-by-m matrix of doubles, the probability of getting success in a Bernoulli trial. pr in (0,1].
a 1x1 matrix of floating point integers, the number of rows of R
a 1x1 matrix of floating point integers, the number of columns of R
a matrix of doubles, the random numbers in the set {0,1,2,3,...}.
Generates random variables from the Geometric distribution function.
Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.
Note - The output argument R belongs to the set {0,1,2,3,...}.
This is not compatible with the grand(m,n,"geom",p)
function in Scilab v5,
where the choice is the set {1,2,3,...}.
In other words, the calling sequence
R = grand(m,n,"geom",pr)
is equivalent to
R = distfun_geornd(pr,m,n) + 1
// set the initial seed for tests distfun_seedset(1); // Test with expanded pr computed = distfun_geornd(1 ./(1:6)) expected = [1 0 14 4 12 0]; // Check expansion of pr in R = distfun_geornd(pr) distfun_seedset(1); N = 10; computed = distfun_geornd(1 ./(1:6)) // Check R = distfun_geornd(pr,v) computed = distfun_geornd(0.2,[4 5]) // Check mean and variance N = 5000; pr = 0.3; R = distfun_geornd(pr,[1 N]); RM = mean(R) RV = variance(R) [M,V] = distfun_geostat(pr) // Check actual distribution pr=0.7; N=10000; R=distfun_geornd(pr,1,N); Rmax=max(R); h=scf(); distfun_inthisto(R); h.children.children(1).children.background=-2; M=distfun_geostat(pr); x=0:Rmax; y=distfun_geopdf(x,pr); plot(x,y,"ro-"); xtitle("Geometric Random Numbers","X","Density") legend(["Empirical","Density"]); | ![]() | ![]() |
http://en.wikipedia.org/wiki/Geometric_distribution