# RANDP 1.0

OS : Windows / Linux / Mac OS / BSD / Solaris

Script Licensing : Freeware

Created : Sep 18, 2007

Downloads : 2

Thank you for voting...

## RANDP - random integers with given probabilities<br ...

RANDP by Josh - random integers with given probabilities

R = RANDP 1.0(P, N) is an N-by-N matrix with random entries on the interval

[1, NUMEL(P)], chosen from the distribution specified by P.

RANDP [randp1.0.exe](P, M, N) and RANDP - 0MB(P, [M, N]) are M-by-N matrices with random entries.

RANDP 1.0(P, M, N, O, . . . ) or RANDP(P, [M, N, P, . . . ]) generate random arrays.

RANDP(P, SIZE(A)) is the same size as A.

For large N, the ratio "sum(R(:)==i)/sum(R(:)==j)" approximates

"P(i)/P(j)" for two integers i and j in the range [1, NUMEL(P)].

% about 10%, 2 about 30% and 3 about 60%

R = randp([1 3 6], 10000, 1) ;

sum(R(:)==1)/sum(R(:)==3)

% should be ~ 1/6

% randomly select 100 elements according to a specific distribution

V = {'Red', 'Green', 'Blue'} ;

ind = randp([80 10 10], 200, 1) ;

R = V(ind) ; % should contain about 160 'Red'

See also RAND, RANDSAMPLE (Matlab 7 Stats Toolbox)

R = RANDP 1.0(P, N) is an N-by-N matrix with random entries on the interval

[1, NUMEL(P)], chosen from the distribution specified by P.

RANDP [randp1.0.exe](P, M, N) and RANDP - 0MB(P, [M, N]) are M-by-N matrices with random entries.

RANDP 1.0(P, M, N, O, . . . ) or RANDP(P, [M, N, P, . . . ]) generate random arrays.

RANDP(P, SIZE(A)) is the same size as A.

For large N, the ratio "sum(R(:)==i)/sum(R(:)==j)" approximates

"P(i)/P(j)" for two integers i and j in the range [1, NUMEL(P)].

**Examples:**

% generate a 10000-by-1 matrix with random entries [1, 3] in which 1 occurs% about 10%, 2 about 30% and 3 about 60%

R = randp([1 3 6], 10000, 1) ;

sum(R(:)==1)/sum(R(:)==3)

% should be ~ 1/6

% randomly select 100 elements according to a specific distribution

V = {'Red', 'Green', 'Blue'} ;

ind = randp([80 10 10], 200, 1) ;

R = V(ind) ; % should contain about 160 'Red'

See also RAND, RANDSAMPLE (Matlab 7 Stats Toolbox)

**• MATLAB Release: R13**

**Demands:****RANDP 1.0 scripting tags:**statistics, matlab randp, integers, random, sumr, generate, statistics probability, matlab statistics.

**What is new in RANDP 1.0 software script?**- Unable to find RANDP 1.0 news.

**What is improvements are expecting?**Newly-made RANDP 1.1 will be downloaded from here. You may download directly. Please write the reviews of the RANDP. License limitations are unspecified.