Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Karren

Posts: 15
Registered: 11/7/11
Re: Repeat Simulation
Posted: Mar 20, 2012 12:23 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.