test.cpptest_path_outstream.csvtest_path_outstream.xlsx
Hi,you all, I'm confused when I tried to test path generator by using pathgenerator.cpp in QuantLib testsuit. Attached please find my testing codes and results related. As you can see in test.cpp, function GeometricBrownianMotionProcess(initialValue, mue, sigma) is used to model the process of path generator. According to following stochastic differential equation, dS = mue*S*dt + sigma*S*dW and E(S)=initialValue*exp(mue*t), we got E(S)=initialValue if mue=0, and dS should be both positive and negative values follow N(0, sigma*S*sqrt(t)). In order to build a path that contains positive numbers with expected value 100(the initialValue), I picked mue=0. But it didn't work as I expected. Please refer to test_path_outstream.csv and test_path_outstream.xlsx. The number became larger and larger(from 100 to 141.132) when variable t goes bigger(from 0 to 10, and dt=0.00033333). It turns out the expected value seems like 120 but not 100. Here my questions are: 1. Why the random numbers generated by PathGenerator(using GeometricBrownianMotionProcess) became larger when mue=0? 2. Is there a way that meets my requirement, which is generating numbers both bigger and smaller than 100 and the expected value is 100, by setting resonable parameters(eg. initialValue, mue, and sigma) of GeometricBrownianMotionProcess? Are there any comments or ideas? Really appreciate it. |
Hi Vivian,
I think you are mistaken one specific path as a whole distribution. Your output is only a specific path of the distribution, so it makes no sense to infer the distribution properties from it. You have to run thousands of samples to get enough data to do the test. I have modified your codes and the each row of the output .csv file is an individual path. You can check that the distribution by examing the data by column. Regards, Cheng -----邮件原件----- 发件人: Vivian Wu [mailto:[hidden email]] 发送时间: 2014年10月29日 13:47 收件人: [hidden email] 主题: [Quantlib-users] Questions about GeometricBrownianMotionProcess - PathGenerator test.cpp <http://quantlib.10058.n7.nabble.com/file/n16004/test.cpp> test_path_outstream.csv <http://quantlib.10058.n7.nabble.com/file/n16004/test_path_outstream.csv> test_path_outstream.xlsx <http://quantlib.10058.n7.nabble.com/file/n16004/test_path_outstream.xlsx> Hi,you all, I'm confused when I tried to test path generator by using pathgenerator.cpp in QuantLib testsuit. Attached please find my testing codes and results related. As you can see in test.cpp, function GeometricBrownianMotionProcess(initialValue, mue, sigma) is used to model the process of path generator. According to following stochastic differential equation, dS = mue*S*dt + sigma*S*dW and E(S)=initialValue*exp(mue*t), we got E(S)=initialValue if mue=0, and dS should be both positive and negative values follow N(0, sigma*S*sqrt(t)). In order to build a path that contains positive numbers with expected value 100(the initialValue), I picked mue=0. But it didn't work as I expected. Please refer to test_path_outstream.csv and test_path_outstream.xlsx. The number became larger and larger(from 100 to 141.132) when variable t goes bigger(from 0 to 10, and dt=0.00033333). It turns out the expected value seems like 120 but not 100. Here my questions are: 1. Why the random numbers generated by PathGenerator(using GeometricBrownianMotionProcess) became larger when mue=0? 2. Is there a way that meets my requirement, which is generating numbers both bigger and smaller than 100 and the expected value is 100, by setting resonable parameters(eg. initialValue, mue, and sigma) of GeometricBrownianMotionProcess? Are there any comments or ideas? Really appreciate it. -- View this message in context: http://quantlib.10058.n7.nabble.com/Questions-about-GeometricBrownianMotionP rocess-PathGenerator-tp16004.html Sent from the quantlib-users mailing list archive at Nabble.com. ---------------------------------------------------------------------------- -- _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users testGeoBrownianMotion.cpp (3K) Download Attachment |
Free forum by Nabble | Edit this page |