ViSP  2.8.0
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 ( )
inline

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 
)
inline

Definition at line 142 of file vpNoise.h.

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

Member Function Documentation

double vpUniRand::draw1 ( )
protectedinherited

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 ( )
inlineprotectedinherited

Definition at line 88 of file vpNoise.h.

Referenced by vpGaussRand().

double vpGaussRand::operator() ( )
inline

Definition at line 163 of file vpNoise.h.

void vpGaussRand::seed ( const long  seed)
inline

Set the seed of the noise

Parameters
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 
)
inline

Set the standard deviation and mean for gaussian noise

Parameters
_snew standard deviation
_mnew mean

Definition at line 156 of file vpNoise.h.

Member Data Documentation

long vpUniRand::x
protectedinherited

Definition at line 86 of file vpNoise.h.

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