randp

バージョン 3.0.01 (2.27 KB) 作成者: Jos (10584)
pseudorandom integers from a specified discrete distribution
ダウンロード: 6K
更新 2019/3/2

ライセンスの表示

RANDP - pseudorandom integers from a specified discrete distribution

R = randp(P, N) returns an N-by-N matrix containing pseudorandom
integers drawn from a specified discrete distribution on 1:numel(P).
The distribution is specified by the relative values of P so that a
value K is present approximately "P(K)/sum(P) times in the matrix R.
All values of P should => 0, NaNs are set to 0.

The other arguments to randp specify the size of R in the same way as
matlab's own functions do: randp(P, N) returns an N-by-N matrix,
randp(P,M,N) and randp(P, [M N]) return M-by-N arrays, etc.

Examples:
% random values from [1 2 4] and a bias for 2
R = randp([1 2 0 1], 1, 100) ; % 100 values
histc(R, 1:4) % -> ~25 ~50 0 ~25

% create a random, but biased DNA sequence
C ='AGCT', P = [4 1 1 2]
DNA = C(randp(P, 1, 50))

引用

Jos (10584) (2024). randp (https://www.mathworks.com/matlabcentral/fileexchange/8891-randp), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2018b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersRandom Number Generation についてさらに検索
謝辞

ヒントを与えたファイル: Generic Fractal Generator

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
3.0.01

new image

3.0

improved help and coding

2.2.0.0

slightly more effective algorithm

2.1.0.0

updated for newer releases

1.14.0.0

implementation of faster algorithm using histc

1.7.0.0

MATLAB Central test

1.0.0.0

fixed error when called with scalar size argument