Haha I'd love to have analytical solution for all types of simulation! Just to say I'm benchmarking a vanilla call option, but I'm using it for other types of path dependent derivatives as well.
On Thursday, 20 February 2014 02:38:44 UTC-5, Alan Edelman wrote: > > Oh and if you like million fold speedups :-) > The analytic expression below gives the exact answer -- no monte carlo > > function callprice(S0, K, r, T, σ) > β= T.^0.5*σ > γ= S0*exp(T*(r-σ^2/2)) > K2 = K/ γ > Cmean = > (e^(β^2/2)*erfc((-β+log(K2)/β)/sqrt(2))-K2*erfc(log(K2)/(β*sqrt(2))))/2 > return exp(-r*T)*Cmean* γ > end > > > On Wednesday, February 19, 2014 10:11:02 AM UTC-5, Alan Edelman wrote: >> >> Just tried this quickly and it ran in half the time on my machine: >> >> function callprice2(S0, K, r, T, σ, paths) >> Csum = 0.0 >> >> β= T.^0.5*σ >> γ= S0*exp(T*(r-σ^2/2)) >> >> >> for j = 1:paths >> Zj = β*randn() >> STj = exp(Zj)* γ >> Csum += max(STj - K,0.0) >> end >> return exp(-r*T)*Csum/paths >> end >> >> >> >> On Monday, February 17, 2014 12:37:11 AM UTC-5, Andreas Noack Jensen >> wrote: >>> >>> Are you referring to the "vectorized version" in MATLAB or julia? On my >>> machine, the version I sent you was slightly slower than MATLAB on one >>> processor and faster in parallel. I am not sure what causes the error you >>> get, but it could look like a problem in JuliaStudio. >>> >>> >>> 2014-02-16 22:43 GMT+01:00 Pithawat Tan Vachiramon <[email protected]>: >>> >>>> Thanks for the code, I tried it and now runs only slightly slower than >>>> vectorized version. As Stefan said the global variable is causing a huge >>>> slow down. >>>> >>>> I tried addprocs(2) but I get this error. My Julia version is version >>>> 0.2 (came with Julia Studio). >>>> >>>> fatal error on 10: ERROR: ConsoleLogic not defined in deserialize at >>>> serialize.jl:334 >>>> in handle_deserialize at serialize.jl:322 >>>> in deserialize at serialize.jl:372 >>>> in handle_deserialize at serialize.jl:322 >>>> in deserialize at serialize.jl:361 >>>> in handle_deserialize at serialize.jl:322 >>>> in deserialize at serialize.jl:305 >>>> in anonymous at serialize.jl:325 >>>> in ntuple at tuple.jl:26 >>>> in deserialize_tuple at serialize.jl:325 >>>> in handle_deserialize at serialize.jl:317 >>>> in deserialize at serialize.jl:360 >>>> in handle_deserialize at serialize.jl:322 >>>> in anonymous at task.jl:822 >>>> ProcessExitedException() >>>> >>>> >>>> julia> >>>> Worker 10 terminated. >>>> ERROR: read: end of file >>>> in yield at multi.jl:1540 >>>> in wait at task.jl:117 >>>> in wait_full at multi.jl:557 >>>> in remotecall_fetch at multi.jl:657 >>>> in call_on_owner at multi.jl:704 >>>> in fetch at multi.jl:712 >>>> in mr_pairwise at reduce.jl:135 >>>> in mapreduce at reduce.jl:158 >>>> in preduce at multi.jl:1435 >>>> in timecallprice at /Users/tanvach/Desktop/Julia/calloption.jl:1509 >>>> in on_eval_msg at /Applications/JuliaStudio.app/Contents/Resources/ >>>> Console/ConsoleLogic.jl:24 >>>> in handle_input at /Applications/JuliaStudio.app/Contents/Resources/ >>>> Console/ConsoleLogic.jl:131 >>>> in anonymous at /Applications/JuliaStudio.app/Contents/Resources/ >>>> Console/ConsoleLogic.jl:144 >>>> in handle_pending_events at /Applications/JuliaStudio.app/Contents/ >>>> Resources/juliet/src/modules/event/event.jl:84 >>>> in update at /Applications/JuliaStudio.app/Contents/Resources/juliet/ >>>> src/modules/event/event.jl:59 >>>> in event_loop at /Applications/JuliaStudio.app/Contents/Resources/ >>>> juliet/src/modules/event/event.jl:72 >>>> in run at /Applications/JuliaStudio.app/Contents/Resources/juliet/src/ >>>> juliet-engine.jl:48 >>>> in include at boot.jl:238 >>>> in include_from_node1 at loading.jl:114 >>>> in process_options at client.jl:303 >>>> in _start at client.jl:389 >>>> >>>> >>>> >>>> >>>> >>> >>> >>> -- >>> Med venlig hilsen >>> >>> Andreas Noack Jensen >>> >>
