Prev: BIJECTION ISSUE, iradon(radon(L*L)) --->(L+2)^2
Next: Help reading in TMY3 (.csv files) data into Matlab
From: nuclph nuclph on 17 May 2010 17:29 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!
From: nuclph nuclph on 17 May 2010 17:55 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 clear all; nsim = 1000; nbins = 100; z_mc = randn(1,nsim); qmc=sobolset(1,'Skip',1e3); qmc=net(qmc,nsim); z_qmc=norminv(qmc,0,1); subplot(2,1,1); hist(z_mc,nbins); title('MC'); subplot(2,1,2); hist(z_qmc,nbins); title('Sobol QMC'); "nuclph nuclph" <bskorodo(a)gmail.com> wrote in message <hsscf2$r8g$1(a)fred.mathworks.com>... > 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!
From: Fabian León on 11 Jun 2010 09:47
Hi, I've extended and commented your example. Thanks % 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'); |