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


So, Michael Stahl commented in the bug that we do have our own
random number generator function.  One way is to just replace the
direct call to rand() to this function instead.  That should be very
easy to do and I have no objection against it.

Just to be clear, I believe glibc's implementation of rand() is
excellent and doesn't need replacement unless one needs particular
statistical properties (the problem is only with windows rand()).
Boost offers generators I believe similar to glibc's rand() as well as
a few which have even better statistical properties but are slower.
The advantage of boost is that it includes transformations which lead
to all sorts of distributions ([0-1] uniform, normal, exponential ...).
This would allow for easy implementation of new functions like

 RANDNORMAL(mu, sigma)

As for the bug report, if he's referring to 

 ./core/sal/inc/rtl/random.h

then I can't see any function we can easily use for our purposes. It
seems to me all this does is generating and managing a random binary
array. From a quick look at the source it seems to use the
Wichmann-Hill algorithm, which apparently has a period of 16 million
(2^24) which is worse than glibc's rand().

Cheers, Tino

 ./core/sal/rtl/source/random.cxx

        #define RTL_RANDOM_RNG(x, y, z) \
        { \
            (x) = 170 * ((x) % 178) - 63 * ((x) / 178); \
            if ((x) < 0) (x) += 30328L; \
            \
            (y) = 171 * ((y) % 177) -  2 * ((y) / 177); \
            if ((y) < 0) (y) += 30269L; \
            \
            (z) = 172 * ((z) % 176) - 35 * ((z) / 176); \
            if ((z) < 0) (z) += 30307L; \
        }


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.