YARP
Yet Another Robot Platform
yarp::math::Rand Class Reference

A static class grouping function for uniform random number generator. More...

#include <yarp/math/Rand.h>

Static Public Member Functions

static double scalar ()
 Get a random number from a uniform distribution in the range [0,1]. More...
 
static double scalar (double min, double max)
 Get a random number from a uniform distribution in the range [min,max]. More...
 
static yarp::sig::Vector vector (int s)
 Get a vector of random numbers from a uniform distribution, values are in the range [0, 1]. More...
 
static yarp::sig::Matrix matrix (int r, int c)
 Get a vector of random numbers from a uniform distribution, values are in the range [0, 1]. More...
 
static yarp::sig::Vector vector (const yarp::sig::Vector &min, const yarp::sig::Vector &max)
 Get a vector of random numbers from a uniform distribution, values are in the range [min, max], for each components. More...
 
static void init ()
 Initialize the random number generator, with current time (time(0)). More...
 
static void init (int seed)
 Initialize the random number generator, provide a seed. More...
 

Detailed Description

A static class grouping function for uniform random number generator.

Thread safe.

Methods inside this class provides access to a global instance of a RandScalar object that generates random numbers.

Definition at line 41 of file Rand.h.

Member Function Documentation

◆ init() [1/2]

void Rand::init ( )
static

Initialize the random number generator, with current time (time(0)).

Definition at line 72 of file Rand.cpp.

◆ init() [2/2]

void Rand::init ( int  seed)
static

Initialize the random number generator, provide a seed.

Parameters
seeda seed.

Definition at line 77 of file Rand.cpp.

◆ matrix()

Matrix Rand::matrix ( int  r,
int  c 
)
static

Get a vector of random numbers from a uniform distribution, values are in the range [0, 1].

Parameters
rnumber of rows
cnumber of columns
Returns
the random matrix

Definition at line 105 of file Rand.cpp.

◆ scalar() [1/2]

double Rand::scalar ( )
static

Get a random number from a uniform distribution in the range [0,1].

Definition at line 62 of file Rand.cpp.

◆ scalar() [2/2]

double Rand::scalar ( double  min,
double  max 
)
static

Get a random number from a uniform distribution in the range [min,max].

Parameters
minlower bound
maxupper bound
Returns
return value

Definition at line 67 of file Rand.cpp.

◆ vector() [1/2]

Vector Rand::vector ( const yarp::sig::Vector min,
const yarp::sig::Vector max 
)
static

Get a vector of random numbers from a uniform distribution, values are in the range [min, max], for each components.

The function determines the size of the vector from the parameters.

Parameters
mina vector whose components specify the lower bound of the distribution.
maxa vector whose components specify the upper bound of the distribution
Returns
the random vector

Definition at line 93 of file Rand.cpp.

◆ vector() [2/2]

Vector Rand::vector ( int  s)
static

Get a vector of random numbers from a uniform distribution, values are in the range [0, 1].

Parameters
sthe size of the vector
Returns
the random vector

Definition at line 82 of file Rand.cpp.


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