[mlpack-svn] [MLPACK] #202: Random number generator from a normal distribution
MLPACK Trac
trac at coffeetalk-1.cc.gatech.edu
Thu Feb 16 12:56:13 EST 2012
#202: Random number generator from a normal distribution
-----------------------------+----------------------------------------------
Reporter: pram | Owner:
Type: wishlist | Status: closed
Priority: major | Milestone:
Component: mlpack | Resolution: fixed
Keywords: random numbers | Blocking:
Blocked By: |
-----------------------------+----------------------------------------------
Changes (by rcurtin):
* status: new => closed
* resolution: => fixed
Comment:
I added `RandNormal()` which gives numbers on the standard normal
distribution as well as an overload which takes a mean and variance. I
don't want to wrap all the distributions there, so if we have any other
commonly-used ones, we can add them to random.hpp but it's fairly easy to
use one of the other ones in your code:
{{{
// some stuff
...
// Now I need a random number!
boost::random::cauchy_distribution<> dist;
double randomNumber = dist(randGen);
}}}
This exploits the global object 'randGen', which is basically the random
seed object all the Boost random number generators use (it's defined in
random.hpp and is of type boost::random::mt19937).
Careful though -- before Boost 1.47, all of the Boost.Random stuff was
just in the boost namespace; now, it's in boost::random. You can see how
I handle this in random.hpp pretty easily.
Let me know if maybe there is a better name we could use than
RandNormal().
--
Ticket URL: <http://trac.research.cc.gatech.edu/fastlab/ticket/202#comment:2>
MLPACK <www.fast-lab.org>
MLPACK is an intuitive, fast, and scalable C++ machine learning library developed by the FASTLAB at Georgia Tech under Dr. Alex Gray.
More information about the mlpack-svn
mailing list