ViSP  2.6.2
vpGaussRand Class Reference

#include <vpNoise.h>

+ Inheritance diagram for vpGaussRand:

Public Member Functions

 vpGaussRand ()
 vpGaussRand (const double sqrtvariance, const double _mean, const long seed=0)
void setSigmaMean (const double _s, const double _m)
void seed (const long seed)
double operator() ()

Protected Member Functions

double draw1 ()
void init ()

Protected Attributes

long x

Detailed Description

Class for generating random number with normal probability density.

The algorithms and notations used are described in "Random Number Generation and Monte Carlo Methods", James E. Gentle, Springer 1998

The code below shows how to use the random generator.

#include <iostream>
#include <visp/vpNoise.h>
int main()
vpGaussRand noise(0.5, 0);
for(int i=0; i< 10; i++) {
std::cout << "noise " << i << ": " << noise() << std::endl;
return 0;

Definition at line 133 of file vpNoise.h.

Constructor & Destructor Documentation

vpGaussRand::vpGaussRand ( )

Definition at line 141 of file vpNoise.h.

References vpUniRand::init(), and vpUniRand::x.

vpGaussRand::vpGaussRand ( const double  sqrtvariance,
const double  _mean,
const long  seed = 0 

Definition at line 142 of file vpNoise.h.

References vpUniRand::init(), seed(), and vpUniRand::x.

Member Function Documentation

double vpUniRand::draw1 ( )

Bays-Durham Shuffling of Park-Miller generator.

Minimal random number generator of Park and Miller with Bays-Durham shuffle. Returns a uniform random deviate between 0.0 and 1.0 (exclusive of the endpoint values).

Definition at line 83 of file vpNoise.cpp.

References vpUniRand::x.

void vpUniRand::init ( )

Definition at line 88 of file vpNoise.h.

Referenced by vpGaussRand().

double vpGaussRand::operator() ( )

Definition at line 163 of file vpNoise.h.

void vpGaussRand::seed ( const long  seed)

Set the seed of the noise

seednew seed

Definition at line 162 of file vpNoise.h.

References seed(), and vpUniRand::x.

Referenced by seed(), and vpGaussRand().

void vpGaussRand::setSigmaMean ( const double  _s,
const double  _m 

Set the standard deviation and mean for gaussian noise

_snew standard deviation
_mnew mean

Definition at line 156 of file vpNoise.h.

Member Data Documentation

long vpUniRand::x

Definition at line 86 of file vpNoise.h.

Referenced by vpUniRand::draw1(), seed(), and vpGaussRand().