annotate 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
rev   line source
samer@11 1 function X=randnat(M,varargin)
samer@11 2 % randnat - Draw Random natural numbers from uniform distribution
samer@11 3 %
samer@11 4 % randnat ::
samer@11 5 % M:natural ~'maximum value',
samer@11 6 % D:[[1,E]] ~'size of E-dimensional array'
samer@11 7 % -> [[D]->[M]] ~'size D array of numbers in 1..M'.
samer@11 8 %
samer@11 9 % The size is specified as in the RAND function, except that if
samer@11 10 % only one dimension is given, we create a vector, not a square
samer@11 11 % matrix, eg
samer@11 12 %
samer@11 13 % randnat(10,3) :: [[3,3]->[10]].
samer@11 14 % randnat(20,2,5,7) :: [[2,5,7]->[20]].
samer@11 15 % randnat(20,5) :: [[5,1]->[20]].
samer@11 16
samer@11 17 X=1+floor(M*rand(tosize(varargin{:})));
samer@11 18