Mercurial > hg > trimatlab
comparison private/randnat.m @ 11:0e0f2805ef9c
Added new mechanism for checking Markov chains for uniqueness of stationary distribution;
new supporting files and new parameters to mt_init (see CHANGES).
Some functions require greater Matlab library, not included.
author | samer |
---|---|
date | Sun, 26 Feb 2012 23:11:10 +0000 |
parents | |
children | a6d5597bd922 |
comparison
equal
deleted
inserted
replaced
10:bce0bd672b47 | 11:0e0f2805ef9c |
---|---|
1 function X=randnat(M,varargin) | |
2 % randnat - Draw Random natural numbers from uniform distribution | |
3 % | |
4 % randnat :: | |
5 % M:natural ~'maximum value', | |
6 % D:[[1,E]] ~'size of E-dimensional array' | |
7 % -> [[D]->[M]] ~'size D array of numbers in 1..M'. | |
8 % | |
9 % The size is specified as in the RAND function, except that if | |
10 % only one dimension is given, we create a vector, not a square | |
11 % matrix, eg | |
12 % | |
13 % randnat(10,3) :: [[3,3]->[10]]. | |
14 % randnat(20,2,5,7) :: [[2,5,7]->[20]]. | |
15 % randnat(20,5) :: [[5,1]->[20]]. | |
16 | |
17 X=1+floor(M*rand(tosize(varargin{:}))); | |
18 |