Boost logo

Boost :

Subject: Re: [boost] Low discrepancy sequences (Boost.Random)
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-04-09 16:46:39


AMDG

Justinas V. D. wrote:
> Aha. So I have added the discard member function, deleted those
> constants (min_value, max_value, etc.). Seems like we are good to go,
> except for the missing member function template<class Sseq> void
> seed(Sseq& q) and the matching constructor.
>
> My previous take that made you uneasy about the exposed internal data
> was something similar to this, but I don't think I will reimplement
> those until we have SeedSequence concept in Boost.Random. I can see
> the value of such members. They would allow easier experiments with
> seeding and would be left to experts only.

What exactly would this constructor do? It looks to me as though,
if it jest set the initial state, then (for a one-dimensional generator)
the effective result would be as though you xor'ed the initial state
with the normal values of the generator.

> Anyway, I removed X::dimension constant and spelled X::dim() as
> X::dimension().

Okay.

>>
>> I think it would be enough if you conveyed the intuitive idea that
>> a low discrepancy sequence is more evenly distributed than a
>> truly random sequence would be.
>
> I have updated concepts.qbk (diff is in Vault). What do you think?

I've tweaked the working a little bit. The resulting patch is attached.
Also, if you use LaTex in the Doxygen comments, enclose it in \f$\f$ so
it will be processed. If you want macros to be expanded by doxygen,
you need to add them to the predefined macros section of the doxyfile.

The following test case breaks because min and max are not defined correctly
#include <boost/random/niederreiter_base2.hpp>

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(test_niederreiter_base2_1d) {
    boost::niederreiter_base2_1d gen;
    for(int i = 0; i < 100; ++i) {
        int val = gen();
        BOOST_CHECK_GE(val, (gen.min)());
        BOOST_CHECK_LE(val, (gen.max)());
    }
}

Finally, since the algorithm does a lot of bit-twiddling,
would uint32_t be more appropriate than int?

In Christ,
Steven Watanabe




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk