Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Topic: Repeat Simulation
Replies: 14   Last Post: Jul 30, 2012 6:39 PM

 Messages: [ Previous | Next ]
 Karren Posts: 15 Registered: 11/7/11
Re: Repeat Simulation
Posted: Mar 20, 2012 12:23 AM

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jk8c4l\$di1\$1@speranza.aioe.org>...
> On 3/19/2012 4:58 PM, Karren wrote:
>

> >> --------------------------------
> >> [nRow,nCol]=size(V);
> >>
> >> SP_risk_neutral=zeros(nRow,1); %allocate space for simulation result
> >> r=...;
> >> d=...;
> >> sigma=...;
> >> T=...;
> >> NRepl=...;
> >>
> >> for i=1:nRow
> >> SP_risk_neutral(i)=Gen_SP_risk_neutral(V(i,2),r,d,sigma,T,V(i,1),NRepl);
> >> end
> >> ----------------------------

>
>

> >
> > Thanks very much for the guide. It does help a lot but there is an error from the following
> >
> > for i = 1:nRow
> > SP_risk_neutral(i)= Gen_SP_risk_neutral(V(i,2), r, d, sigma, dt, V(i,1),NRepl);
> > end
> >
> > ERROR MESSAGE
> > In an assignment A(I) = B, the number of elements in B and I must be the same.
> >

>
> I do not know what your function Gen_SP_risk_neutral() returns. It
> looks like it returns a matrix or a vector.
>
> You need to allocate space to store the result of your
> Gen_SP_risk_neutral for all the simulation steps.
>
> i.e. allocate space (using the zeros function) for SP_risk_neutral
> such that it matches what the function Gen_SP_risk_neutral returns.
>
> hth,
>
> --Nasser

The function returns a matrix, i.e. NRepl x NSteps for each simulation.

Karren

Date Subject Author
3/15/12 Karren
3/15/12 Nasser Abbasi
3/16/12 Karren
3/16/12 Nasser Abbasi
3/18/12 Karren
3/18/12 Nasser Abbasi
3/18/12 Karren
3/19/12 Nasser Abbasi
3/19/12 Karren
3/19/12 Nasser Abbasi
3/20/12 Karren
3/20/12 Nasser Abbasi
3/20/12 Karren
3/20/12 Nasser Abbasi
7/30/12 Karren