<< distfun_unidpdf Uniform Discrete distfun_unidstat >>

Distfun >> Distfun > Uniform Discrete > distfun_unidrnd

distfun_unidrnd

Uniform Discrete random numbers

Calling Sequence

x = distfun_unidrnd ( N )
x = distfun_unidrnd ( N , [m,n] )
x = distfun_unidrnd ( N , m , n )

Parameters

N :

a matrix of doubles, integer value, the integer upper bound (with N>=1)

m :

a 1-by-1 matrix of floating point integers, the number of rows of x

n :

a 1-by-1 matrix of floating point integers, the number of columns of x

x:

a matrix of doubles, the random numbers in the set {1,...,N}.

Description

Generates integer random variables from the Uniform discrete distribution function.

Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.

Examples

// Use x = distfun_unidrnd ( N )
x=distfun_unidrnd(7)
x=distfun_unidrnd(2:7)

// Check x = distfun_unidrnd ( N , v )
x = distfun_unidrnd(2,[1 5])
x = distfun_unidrnd(2,[3 2])

// See x = distfun_unidrnd (N,m,n)
x = distfun_unidrnd(3,1,2)

// Check mean and variance for x = distfun_unidrnd ( N )
m = 1000;
N = 2:7;
[M,V] = distfun_unidstat(N)
for i = 1:m
computed(i,1:6) = distfun_unidrnd(N);
end
Mx = mean(computed, "r" )
Vx = variance(computed, "r" )

// Make a plot of the actual distribution of the numbers
N = 10;
h=scf();
x = distfun_unidrnd(N,1,1000);
distfun_inthisto(x);
h.children.children(1).children.background=-2;
x=1:N;
y=distfun_unidpdf(x,N);
plot(x,y,"ro-")
legend(["Data","PDF"]);
xtitle("Uniform random numbers","X","Density");

Authors


Report an issue
<< distfun_unidpdf Uniform Discrete distfun_unidstat >>