random number generators for calc

Kohei Yoshida kohei.yoshida at gmail.com
Wed Nov 28 13:24:21 PST 2012


On 11/28/2012 02:41 PM, tino wrote:
>> Thanks for the additional insight.  Well, I can see two possibilities:
>>
>> 1) Use boost's generator for Windows platform-only, while we keep
>> the glibc's version for Linux.  I wonder what the situation is on
>> Mac...
>>
>> 2) Use boost's generator for all platforms.
>
> If there are no issues with using boost then I'd suggest 2) and use
> boost's implementation of Mersenne Twister (boost::mt19937) as default
> for all.

Yup, I agree with that. That's probably the better approach.

> It also turns out to be slightly faster than rand().

Good.  This was my only concern toward use of boost's generator over 
glibc's.  But now there is one less reason not to use boost's.

> What is your opinion on implementing generators for other
> distributions like normal and all the ones listed under statistics
> (which calculate densities but don't generate)?

Well, re-implementing the existing RAND and RANDBETWEEN with the new 
generator is no brainer.  But I'm not sure if we really need to provide 
multiple variants for different random number generators.  What we could 
do is to specify a run-time option for the algorithm for the normal RAND 
and RANDBETWEEN functions rather than providing multiple variants.  That 
would be my preference.  We already have formula engine options in Tools 
- Options (in the Formula tab page), so adding another one shouldn't be 
too difficult.

With boost this is
> simple so just a matter of extending the UNO interface.

Well, these functions are implemented in the core interpreter in the sc 
module (ScInterpreter).  Not scaddins.  So, no UNO interface involved 
there. :-)

Kohei

-- 
Kohei Yoshida, LibreOffice hacker, Calc


More information about the LibreOffice mailing list