YARP
Yet Another Robot Platform
Random.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3
* All rights reserved.
4
*
5
* This software may be modified and distributed under the terms of the
6
* BSD-3-Clause license. See the accompanying LICENSE file for details.
7
*/
8
9
#include <
yarp/os/Random.h
>
10
11
#include <cmath>
12
#include <cstdlib>
13
#include <random>
14
15
using namespace
yarp::os
;
16
std::default_random_engine
randengine
;
17
18
double
Random::uniform
()
19
{
20
std::uniform_real_distribution<double> udist(0.0, 1.0);
21
return
udist(
randengine
);
22
}
23
24
double
Random::normal
()
25
{
26
return
normal
(0.0, 1.0);
27
}
28
29
double
Random::normal
(
double
m,
double
s)
30
{
31
std::normal_distribution<double> ndist(m, s);
32
return
ndist(
randengine
);
33
}
34
35
void
Random::seed
(
int
seed)
36
{
37
randengine
.seed(
seed
);
38
}
39
40
41
int
Random::uniform
(
int
min,
int
max)
42
{
43
std::uniform_int_distribution<int> udist(min, max);
44
return
udist(
randengine
);
45
}
randengine
std::default_random_engine randengine
Definition:
Random.cpp:16
yarp::os::Random::uniform
static double uniform()
Generates a random number in the range 0 to 1.
Definition:
Random.cpp:18
yarp::os::Random::normal
static double normal()
Definition:
Random.cpp:24
Random.h
Contains methods and classes for generating random numbers with various (simple) distributions.
yarp::os
An interface to the operating system, including Port based communication.
Definition:
AbstractCarrier.h:17
yarp::os::Random::seed
static void seed(int seed)
Sets the seed of the random number generator.
Definition:
Random.cpp:35
YARP
3.4.100+20201223.2+gitb8ea4d712
src
libYARP_os
src
yarp
os
Random.cpp
Generated on Sun Jan 3 2021 02:46:25 for YARP by
1.8.20