October 27th, 2014, 1:21 pm
QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: MiloRambaldiQuoteOriginally posted by: outrunQuoteOriginally posted by: MiloRambaldiI was looking at QuantLib's implementation and it is closely tied to the MT19937 (Mersenne Twister) generator. That's a design flaw, they should have used orthogonal concepts and reuse standard concepts, abstract away specifics as much as possible. Now they can only eat their own spaghetti food. It's an old project, it's alway easy to judge in retrospect but e.g. Efficient C++ by Scott Meyers has been around for ages. QuoteIt only uses 24-bits of the MT output to avoid some correlation issue.Do you know if these issues have been resolved in boost? I cannot find the post you once made here about ziggurat quality issues.The issue seems to be with MT, not with ziggarat. MT is standardised algorithm (with some constants) which should be *identical* across implementations, so boost can't 'fix' MT, nor ziggurat, the combination is apparently invalid? It would be interesting if you have some more info about that issue?To be fair, QuantLib's polar Box-Muller appears to be well-designed with appropriate orthogonality and abstraction. Perhaps there is some reason that their Ziggurat hard-codes MT. I plan to look into this further very soon.Several possible reasons for putting BM into history:1. slow: it uses log, sqrt, sin, cos2. Peter Jaeckel in his book discusses nasty side-effects with this method; it goes haywire with pseudo-random algorithms.3. It is claimed that BM is mucho slower than Ziggurat, especially for large numbers of random numbers.Are these good reason for not using BM?QuoteThat's a design flaw, they should have used orthogonal concepts and reuse standard concepts, abstract away specifics as much as possible.In fairness, the QL code is shipping now.I all but stopped open source coding more than year ago due to (severe) financial distress. But I did add some speed comparison tests for various methods of normal univariate psuedo-random number generation, including QL Ziggurat and QL Polar Box-Muller and Boost and C++11 Box-Muller (using the basic method IIRC). I will try to dig it up this week since there is some interest here. outrun seems to have a point about the "design flaw" of QL hard-coding the MT engine for the Ziggurat generator. I looked at the code and the paper on Ziggurat that it was based on, and could not see any reason why other engines could not be used. On the other hand, IIRC QL's Ziggurat was the fastest. Also, the Ziggurat code was in the experimental folder of Quantlib-1.3 (I haven't checked the status in the new version 1.4).