<< distfun_geopdf Geometric distfun_geostat >>

Distfun >> Distfun > Geometric > distfun_geornd

distfun_geornd

Geometric random numbers

Calling Sequence

R = distfun_geornd(Pr)
R = distfun_geornd(Pr,v)
R = distfun_geornd(Pr,m,n)

Parameters

Pr :

a 1x1 or nxm matrix of doubles, the probability of getting success in a Bernoulli trial

v :

a 1x2 or 2x1 matrix of doubles, the size of R

v(1) :

the number of rows of R

v(2) :

the number of columns of R

m :

a 1x1 matrix of floating point integers, the number of rows of R

n :

a 1x1 matrix of floating point integers, the number of columns of R

R:

a matrix of doubles, the random numbers.

Description

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.

As a side effect, it modifies the internal seed of the grand function.

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

Examples

// 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;
computed1(1:6,i) = distfun_geornd(1 ./(1:6))

// Check R = distfun_geornd(Pr,v)
computed = distfun_geornd(0.2,[4 5])
assert_checkequal(size(computed),[4 5]);

// Check mean and variance
N = 5000;
Pr = 0.3;
computed = distfun_geornd(Pr,[1 N]);
c = mean(computed(1:N))
d = st_deviation(computed(1:N) )
[M,V] = distfun_geostat (Pr)

Bibliography

http://en.wikipedia.org/wiki/Geometric_distribution

Authors


<< distfun_geopdf Geometric distfun_geostat >>