Random number generator based on normal distribution with Boost

Yesterday I was looking for some random number generator, based on gaussian distribution. As I don’t like to reinvent the wheel, I started to look for some already existing solutions. I found out that Boost library provided a very powerful engine for generating random numbers using various algorithms. The whole description of Boost Random Number library is available here.

For those who are looking for already existing solutions I attach a small snippet, which generates random numbers basing on the normal distribution. As typical for gaussian distribution, the algorithm takes two parameters: mean value and sigma(variance).


GetRandomDoubleUsingNormalDistribution(double mean,
                    double sigma)
 typedef boost::normal_distribution NormalDistribution;
 typedef boost::mt19937 RandomGenerator;
 typedef boost::variate_generator GaussianGenerator;

  /** Initiate Random Number generator with current time */
  static RandomGenerator rng(static_cast (time(0)));

  /* Choose Normal Distribution */
  NormalDistribution gaussian_dist(mean, sigma);
  /* Create a Gaussian Random Number generator
   *  by binding with previously defined
   *  normal distribution object
  GaussianGenerator generator(rng, gaussian_dist);
  // sample from the distribution
  return generator();

Fuzzy Logic Controller

This project is an exemplary application of fuzzy logic for controlling different types of processes. I wrote it for an Artificial Intelligence course in Windesheim University of Applied Sciences. The assignment is composed of four components:

  • Knowledge base
  • Knowledge base parser
  • Fuzzy Logic Controler
  • Controlled process

Read More