Hi all,
This is my first posting on the Quantlib Users forum. I am currently working on a small random numbers generation framework for a simulation model, and using the class template RandomSequenceGenerator<> with the Mersenne Twister generator provided with QL. I generate 30 scenarios per time point, along 80 time points or so. I noticed that the format of the numbers outputted on my std::out is set to some weird floating representations (e-294, etc…) and after a while the generator sets the numbers to 0. Any help on this will be very much appreciated, Thanks, Amine ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users signature.asc (859 bytes) Download Attachment |
Hello Amine, Luigi On Fri, Jan 27, 2017, 14:01 Amine Ifri <[hidden email]> wrote: Hi all, ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Amine,
I'm adding the mailing list back in cc so that others can help. About your code: it's difficult to say what goes wrong without seeing, for instance, how your generator_ instance is created. Adding that part of your code would help. This said, a few suggestions: - you might try printing out the values of v and w inside CreateCorrelatedUniformNumbers, in order to check what comes out of the generator and what it becomes after it's multiplied by the correlation; - you might want to print out values_ after the generation, to make sure that you're copying it correctly out of the getValues() method; - also, you probably got your call to the generator at the wrong point in the loop. Right now it's inside both the (for i...) and the (for j...) loop, which means that you're sampling a whole vector, then you copy only w[i], then you throw the rest away and sample another whole vector. I'm guessing you wanted something like the following instead: for (int j=0; j<timesteps; ++j) { v = (generator_.nextSequence()).value; ... for (int i=0; i<w.size(); ++i) { (values_[i])(k,j) = w[i]; } } or some other loop structure. Later, Luigi On Fri, Jan 27, 2017 at 2:13 PM Amine Ifri <[hidden email]> wrote:
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Luigi, all, Just to give you the heads up that the below matter is closed. It was more an error of printing the values rather than a design problem. The small bit I have written creates a simulation framework where one can leverage the already developed Random sequence generators from QL to build a set of correlated gaussians (via Square factorisation, e.g Cholesky), per asset, time point/scenario. This comes handy for evolving stochastic processes through time and scenario for application in credit exposure calculations. Happy to share my code… cheers, Amine
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users signature.asc (859 bytes) Download Attachment |
Free forum by Nabble | Edit this page |