Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Generate samples in Monte Carlo simulation

Subject: Generate samples in Monte Carlo simulation

From: kumar vishwajeet

Date: 21 Jul, 2011 22:22:10

Message: 1 of 6

Hi,
I need to generate samples for monte carlo simulation. The mean and covariance of the state is m and s. It is given that the state has gaussian distribution at t = 0.Which of the following is the better and more accurate way to generate samples??
1. m + sqrt(s)*randn(1,1)
2. m + 3*sqrt(s)*randn(1,1).
Second method assumes that 99% of a gaussian pdf is concentrated within a distance of 3 times its standard deviation from the mean.
Will the first method be less accurate??

Thanks,
Vishwajeet

Subject: Generate samples in Monte Carlo simulation

From: TideMan

Date: 21 Jul, 2011 22:47:23

Message: 2 of 6

On Jul 22, 10:22 am, "kumar vishwajeet" <kwz...@gmail.com> wrote:
> Hi,
> I need to generate samples for monte carlo simulation. The mean and covariance of the state is m and s. It is given that the state has gaussian distribution at t = 0.Which of the following is the better and more accurate way to generate samples??
> 1. m + sqrt(s)*randn(1,1)
> 2. m + 3*sqrt(s)*randn(1,1).
> Second method assumes that 99% of a gaussian pdf is concentrated within a distance of 3 times its standard deviation from the mean.
> Will the first method be less accurate??
>
> Thanks,
> Vishwajeet

What makes you think that multiplying by 3 will increase the
"accuracy"?

In fact, multiplying by 3 will simply scale up the standard deviation
of the generated numbers three-fold.

Subject: Generate samples in Monte Carlo simulation

From: kumar vishwajeet

Date: 21 Jul, 2011 23:00:12

Message: 3 of 6

TideMan <mulgor@gmail.com> wrote in message <ae11522d-b7ca-4cd0-91ab-d78889c0e49d@u6g2000prc.googlegroups.com>...
> On Jul 22, 10:22 am, "kumar vishwajeet" <kwz...@gmail.com> wrote:
> > Hi,
> > I need to generate samples for monte carlo simulation. The mean and covariance of the state is m and s. It is given that the state has gaussian distribution at t = 0.Which of the following is the better and more accurate way to generate samples??
> > 1. m + sqrt(s)*randn(1,1)
> > 2. m + 3*sqrt(s)*randn(1,1).
> > Second method assumes that 99% of a gaussian pdf is concentrated within a distance of 3 times its standard deviation from the mean.
> > Will the first method be less accurate??
> >
> > Thanks,
> > Vishwajeet
>
> What makes you think that multiplying by 3 will increase the
> "accuracy"?
>
> In fact, multiplying by 3 will simply scale up the standard deviation
> of the generated numbers three-fold.

Multiplying by 3 ensures that we are able to capture points beyond 1 sigma. Since, the initial state pdf is gaussian, we need to capture all the points upto 3 standard deviation for accuracy upto 99%. This is what I think. But I am not sure about that and I need opinion.

Subject: Generate samples in Monte Carlo simulation

From: Roger Stafford

Date: 21 Jul, 2011 23:44:09

Message: 4 of 6

"kumar vishwajeet" wrote in message <j0ab1s$gdn$1@newscl01ah.mathworks.com>...
> TideMan <mulgor@gmail.com> wrote in message <ae11522d-b7ca-4cd0-91ab-d78889c0e49d@u6g2000prc.googlegroups.com>...
> > On Jul 22, 10:22 am, "kumar vishwajeet" <kwz...@gmail.com> wrote:
> > > Hi,
> > > I need to generate samples for monte carlo simulation. The mean and covariance of the state is m and s. It is given that the state has gaussian distribution at t = 0.Which of the following is the better and more accurate way to generate samples??
> > > 1. m + sqrt(s)*randn(1,1)
> > > 2. m + 3*sqrt(s)*randn(1,1).
> > > Second method assumes that 99% of a gaussian pdf is concentrated within a distance of 3 times its standard deviation from the mean.
> > > Will the first method be less accurate??
> > >
> > > Thanks,
> > > Vishwajeet
> >
> > What makes you think that multiplying by 3 will increase the
> > "accuracy"?
> >
> > In fact, multiplying by 3 will simply scale up the standard deviation
> > of the generated numbers three-fold.
>
> Multiplying by 3 ensures that we are able to capture points beyond 1 sigma. Since, the initial state pdf is gaussian, we need to capture all the points upto 3 standard deviation for accuracy upto 99%. This is what I think. But I am not sure about that and I need opinion.
- - - - - - - - -
  Kumar, you haven't thought this matter through carefully enough. You should listen to TideMan. The fact that 99% fall within three standard deviations is irrelevant. If you multiply by three you will simply broaden the distribution by just that factor. The bell-shaped curve will be three times as wide. The interval in which 99% fall will also be three times as wide.

  I seriously suggest you try out the following with matlab:

 n = 4000;
 m = 4; s = 25; % Any values will do
 x1 = sort(m+sqrt(s)*randn(1,n);
 x2 = sort(m+3*sqrt(s)*randn(1,n);
 plot(x1,1:n,'y',x2,1:n,'r')

See if this plot doesn't tell you that there is something fundamentally amiss with your reasoning.

Roger Stafford

Subject: Generate samples in Monte Carlo simulation

From: Roger Stafford

Date: 21 Jul, 2011 23:51:08

Message: 5 of 6

"Roger Stafford" wrote in message <j0adk9$me4$1@newscl01ah.mathworks.com>...
> ......
> I seriously suggest you try out the following with matlab:
>
> n = 4000;
> m = 4; s = 25; % Any values will do
> x1 = sort(m+sqrt(s)*randn(1,n);
> x2 = sort(m+3*sqrt(s)*randn(1,n);
> plot(x1,1:n,'y',x2,1:n,'r')
>
> See if this plot doesn't tell you that there is something fundamentally amiss with your reasoning.
>
> Roger Stafford
- - - - - - - - -
  I left off two parentheses. It should be:

 x1 = sort(m+sqrt(s)*randn(1,n));
 x2 = sort(m+3*sqrt(s)*randn(1,n));

Roger Stafford

Subject: Generate samples in Monte Carlo simulation

From: TideMan

Date: 21 Jul, 2011 23:51:14

Message: 6 of 6

On Jul 22, 11:00 am, "kumar vishwajeet" <kwz...@gmail.com> wrote:
> TideMan <mul...@gmail.com> wrote in message <ae11522d-b7ca-4cd0-91ab-d78889c0e...@u6g2000prc.googlegroups.com>...
> > On Jul 22, 10:22 am, "kumar vishwajeet" <kwz...@gmail.com> wrote:
> > > Hi,
> > > I need to generate samples for monte carlo simulation. The mean and covariance of the state is m and s. It is given that the state has gaussian distribution at t = 0.Which of the following is the better and more accurate way to generate samples??
> > > 1. m + sqrt(s)*randn(1,1)
> > > 2. m + 3*sqrt(s)*randn(1,1).
> > > Second method assumes that 99% of a gaussian pdf is concentrated within a distance of 3 times its standard deviation from the mean.
> > > Will the first method be less accurate??
>
> > > Thanks,
> > > Vishwajeet
>
> > What makes you think that multiplying by 3 will increase the
> > "accuracy"?
>
> > In fact, multiplying by 3 will simply scale up the standard deviation
> > of the generated numbers three-fold.
>
> Multiplying by 3 ensures that we are able to capture points beyond 1 sigma. Since, the initial state pdf is gaussian, we need to capture all the points upto 3 standard deviation for accuracy upto 99%. This is what I think. But I am not sure about that and I need opinion.

But randn does this for you.
Try this:
N=10000;pc=99;
y=randn(10000,1); % Generate 10000 numbers with unit variance
ysort=sort(y);
alfa=(100-pc)/100/2;
i1=round(alfa*N) + 1; % Location of 0.5%
i2=round((1-alfa)*N) + 1; % Location of 99.5%
[ysort(i1) ysort(i2) ysort(i2)-ysort(i1)]

For 99%, they should be +/- 2.5758

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us