From: Fabian León on 11 Jun 2010 09:44 Hi, I think this could be useful, is an example that I've found, commented and extended. % http://www.mathworks.com/matlabcentral/newsreader/view_thread/282415 % Date: 17 May, 2010 21:29:06 % Hi all, % does any one have an example how to use Matlab capability to generate % random normal variables using Sobol sequence? I have stat add in with % sobolset but not that clear how to use it to get random normal % distribution. % % thanks in advance! % Date: 17 May, 2010 21:55:20 % Hi All, % It seems it is quite easy to do it. See an example below. % Please, let me know if yo have any comments or suggestions. %test quasi monte carlo % Modified example by Fabian León % Date: 11 Juny, 2010 clear all; nsim = 1000; % Vector size. nbins = 100; % Number of bins used to calculate the histogram. z_mc = randn(1,nsim); % Returns an 1-by-nsim matrix (size vector = nsim). s_qmc=sobolset(1,'Skip',nsim); % Set 1-dimensional (vector), and the number % of initial points to omit (Skip = nsim) % In this function the diferent sequences % are set to avoid correlations between each % vector. s_qmc=net(s_qmc,nsim); % Get the first nsim points. z_qmc=norminv(s_qmc,0,1); % Returns the inverse cumulative distribution % function (cdf) for the normal distribution with % mean MU(=0) and standard deviation SIGMA (=1), % evaluated at the values in s_qmc. h_qmc=haltonset(1,'Skip',nsim-100); % Is the same procedure as in sobol % case but with halton and another Skip % value. h_qmc=net(h_qmc,nsim); zz_qmc=norminv(h_qmc,0,1); subplot(3,1,1); hist(z_mc,nbins); title('MC'); subplot(3,1,2); hist(z_qmc,nbins); title('Sobol QMC'); subplot(3,1,3); hist(zz_qmc,nbins); title('Halton QMC');
|
Pages: 1 Prev: Using Builder JA on 64-bit and running with 32-bit MCR Next: Custom axis |