Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


of course it doesn't have fancy features like ranges or non-uniform
distribution...

That's ok, I wouldn't use that against it, because these things are
independent. Any uniform int generator can easily be extended to
ranges, and uniform [0,1] distribution. And at least in theory, any
non-uniform distribution can then be generated using

 rand_some_non_uniform() = F_inv( rand_uniform01() );

where F_inv() is the inverse cdf (cumulative distribution function)
which in practice is not always easily available. Gnumeric has access
to the inverse cdf's through R. Boost also has them implemented
already (not as comprehensive as R though).

Btw, boost has the same structure, boost::mt19937 only generates
integers, and this forms the basis for all other distributions.

... looking at random.cxx it appears to use a MD5 hash to generate the
random bytes; initialization is via seconds/nanoseconds of current time
and thread-id.  since the cryptographic hash implementations in sal/rtl
don't look heavily optimized this is likely not be the fastest way to
generate random numbers, if that is a concern...

Speed is not my concern here (I guess parsing a cell is of an order of
magnitude slower?). My problem is with statistical properties, and
until somebody knows exactly what random.cxx does, I'd advice
against using it. I'm also no expert and I may well be wrong but an
MD5 based random number generator sounds a bit like a home made
generator where we don't even know if it's truly uniform distributed.

We should not implement them in rtl/math.hxx until there are more users
than calc's interpreter that need it. Lets not overcomplicate this stuff
as long as it is not necessary.

What about implementation in random.cxx and creating random.hxx so all
the random stuff is in one place?

Tino


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.