Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

unidrnd - Discrete uniform random numbers

Syntax

R = unidrnd(N)
R = unidrnd(N,v)
R = unidrnd(N,m,n)

Description

R = unidrnd(N) generates random numbers for the discrete uniform distribution with maximum N. The parameters in N must be positive integers. N can be a vector, a matrix, or a multidimensional array. The size of R is the size of N. The discrete uniform distribution arises from experiments equivalent to drawing a number from one to N out of a hat.

R = unidrnd(N,v) generates random numbers for the discrete uniform distribution with maximum N, where v is a row vector. If v is a 1-by-2 vector, R is a matrix with v(1) rows and v(2) columns. If v is 1-by-n, R is an n-dimensional array.

R = unidrnd(N,m,n) generates random numbers for the discrete uniform distribution with maximum N, where scalars m and n are the row and column dimensions of R.

Examples

In the Massachusetts lottery, a player chooses a four-digit number. Generate random numbers for Monday through Saturday.

numbers = unidrnd(10000,1,6)-1
numbers =
    4564  185  8214  4447  6154  7919

See Also

random, unidpdf, unidcdf, unidinv, unidstat

Uniform Distribution (Discrete)

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS