Boost logo

Boost Users :

From: Jeffrey Holle (jeffreyholle_at_[hidden])
Date: 2007-10-05 14:08:25


Brian Stadler wrote:
> A few things,
>
> First, try this when creating your uniform_01 object,
>
> typedef boost::uniform_01<boost::mt19937> random_real; <--you
> typedef'ed it here.
> random_real actual_generator;
> actual_generator() <----to output numbers between 0 and 1.
>
> Two, don't use uniform_01. The uniform_real class works much better
> and defaults to between 0 and 1.
>
>
> Three, it looks like you are wanting random ints 0 and 1, not random
> real numbers between 0 and 1. For this have a look at the uniform_int
> or uniform_smallint class. They are probably what you are looking for.
>
> Hope this helps.
>
> Brian
Thanks for this information.
It looks like I indeed need uniform_smallint, but I'm having trouble
with it. This is what I'm trying to compile:

   std::tr1::mt19937 rng;
   boost::uniform_smallint<int> six(1,6);
   boost::variate_generator<std::tr1::mt19937&,
boost::uniform_smallint<int> > die(rng, six);
   int x = die();

Note this from a boost webpage, with slight modifications.

The compiler error I'm getting is:

../test.cpp:15: error: no matching function for call to
'boost::variate_generator<std::tr1::mt19937&,
boost::uniform_smallint<int> >::variate_generator()'
$BOOST_ROOT/boost/random/variate_generator.hpp:97: note: candidates are:
boost::variate_generator<Engine,
Distribution>::variate_generator(Engine, Distribution) [with Engine =
std::tr1::mt19937&, Distribution = boost::uniform_smallint<int>]

Can somebody point out what my problem is?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net