1 /* Copyright (C) 2006-2008 Joris Mooij [j dot mooij at science dot ru dot nl]
2 Radboud University Nijmegen, The Netherlands
4 This file is part of libDAI.
6 libDAI is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libDAI is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libDAI; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <boost/random/linear_congruential.hpp>
24 #include <boost/random/uniform_real.hpp>
25 #include <boost/random/normal_distribution.hpp>
26 #include <boost/random/variate_generator.hpp>
35 return( tbuf
.tms_utime
);
39 // This is a typedef for a random number generator.
40 // Try boost::mt19937 or boost::ecuyer1988 instead of boost::minstd_rand
41 typedef boost::minstd_rand _rnd_gen_type
;
43 _rnd_gen_type
_rnd_gen(42);
45 // Define a uniform random number distribution which produces "double"
46 // values between 0 and 1 (0 inclusive, 1 exclusive).
47 boost::uniform_real
<> _uni_dist(0,1);
48 boost::variate_generator
<_rnd_gen_type
&, boost::uniform_real
<> > _uni_rnd(_rnd_gen
, _uni_dist
);
50 // Define a normal distribution with mean 0 and standard deviation 1.
51 boost::normal_distribution
<> _normal_dist
;
52 boost::variate_generator
<_rnd_gen_type
&, boost::normal_distribution
<> > _normal_rnd(_rnd_gen
, _normal_dist
);
55 void rnd_seed( int seed
) {
59 double rnd_uniform() {
63 double rnd_stdnormal() {
68 } // end of namespace dai