ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::utility::random::NormalGenerator< T > Class Template Reference

#include <Random.h>

Public Member Functions

 NormalGenerator (const T mean=0.0, const T stddev=1.0)
 
operator() ()
 Call this to generate a normally distributed floating point value. More...
 

Protected Attributes

std::normal_distribution< T > distribution_
 

Detailed Description

template<typename T>
class cloudViewer::utility::random::NormalGenerator< T >

Generate normally distributed floating point values with mean and std. This class is globally seeded by utility::random::Seed(). This class is a wrapper around std::normal_distribution.

Example:

// Globally seed cloudViewer. This will affect all random functions.
// Generate a random double with mean 0 and std 1.
utility::random::NormalGenerator<double> gen(0, 1);
for (size_t i = 0; i < 10; i++) {
std::cout << gen() << std::endl;
}
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
void Seed(const int seed)
Set CloudViewer global random seed.
Definition: Random.cpp:53

Definition at line 154 of file Random.h.

Constructor & Destructor Documentation

◆ NormalGenerator()

template<typename T >
cloudViewer::utility::random::NormalGenerator< T >::NormalGenerator ( const T  mean = 0.0,
const T  stddev = 1.0 
)
inline

Generate normally distributed floating point value with mean and std.

Parameters
meanThe mean of the distribution.
stddevThe standard deviation of the distribution.

Definition at line 160 of file Random.h.

References LogError, and stddev().

Member Function Documentation

◆ operator()()

template<typename T >
T cloudViewer::utility::random::NormalGenerator< T >::operator() ( )
inline

Call this to generate a normally distributed floating point value.

Definition at line 168 of file Random.h.

References cloudViewer::utility::random::NormalGenerator< T >::distribution_, cloudViewer::utility::random::GetEngine(), and cloudViewer::utility::random::GetMutex().

Member Data Documentation

◆ distribution_

template<typename T >
std::normal_distribution<T> cloudViewer::utility::random::NormalGenerator< T >::distribution_
protected

The documentation for this class was generated from the following file: