GNU Radio Manual and C++ API Reference
3.9.1.0
The Free & Open Software Radio Ecosystem
random.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2002, 2015 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
7
* SPDX-License-Identifier: GPL-3.0-or-later
8
*
9
*/
10
11
#ifndef INCLUDED_GR_RANDOM_H
12
#define INCLUDED_GR_RANDOM_H
13
14
#include <
gnuradio/api.h
>
15
#include <
gnuradio/gr_complex.h
>
16
17
#include <cstdlib>
18
#include <ctime>
19
#include <random>
20
21
namespace
gr
{
22
23
/*!
24
* \brief pseudo random number generator
25
* \ingroup math_blk
26
*/
27
class
GR_RUNTIME_API
random
28
{
29
protected
:
30
long
d_seed
;
31
bool
d_gauss_stored
;
32
float
d_gauss_value
;
33
34
std::mt19937
d_rng
;
// mersenne twister as random number generator
35
std::uniform_real_distribution<float>
36
d_uniform
;
// choose uniform distribution, default is [0,1)
37
std::uniform_int_distribution<>
d_integer_dis
;
38
39
public
:
40
random
(
unsigned
int
seed = 0,
int
min_integer = 0,
int
max_integer = 2);
41
~
random
();
42
43
/*!
44
* \brief Change the seed for the initialized number generator. seed = 0 initializes
45
* the random number generator with the system time.
46
*/
47
void
reseed(
unsigned
int
seed);
48
49
/*!
50
* set minimum and maximum for integer random number generator.
51
* Limits are [minimum, maximum)
52
* Default: [0, std::numeric_limits< IntType >::max)]
53
*/
54
void
set_integer_limits(
const
int
minimum,
const
int
maximum);
55
56
/*!
57
* Uniform random integers in the range set by 'set_integer_limits' [min, max).
58
*/
59
int
ran_int();
60
61
/*!
62
* \brief Uniform random numbers in the range [0.0, 1.0)
63
*/
64
float
ran1();
65
66
/*!
67
* \brief Normally distributed random numbers (Gaussian distribution with zero mean
68
* and variance 1)
69
*/
70
float
gasdev();
71
72
/*!
73
* \brief Laplacian distributed random numbers with zero mean and variance 1
74
*/
75
float
laplacian();
76
77
/*!
78
* \brief Rayleigh distributed random numbers (zero mean and variance 1 for the
79
* underlying Gaussian distributions)
80
*/
81
float
rayleigh();
82
83
/*!
84
* \brief Exponentially distributed random numbers with values less than or equal
85
* to factor replaced with zero. The underlying exponential distribution has
86
* mean sqrt(2) and variance 2.
87
*/
88
float
impulse(
float
factor);
89
90
/*!
91
* \brief Normally distributed random numbers with zero mean and variance 1 on real
92
* and imaginary part. This results in a Rayleigh distribution for the amplitude and
93
* an uniform distribution for the phase.
94
*/
95
gr_complex
rayleigh_complex();
96
};
97
98
}
/* namespace gr */
99
100
#endif
/* INCLUDED_GR_RANDOM_H */
gr::random
pseudo random number generator
Definition:
random.h:27
gr::random::d_gauss_value
float d_gauss_value
Definition:
random.h:32
GR_RUNTIME_API
#define GR_RUNTIME_API
Definition:
gnuradio-runtime/include/gnuradio/api.h:18
gr_complex
std::complex< float > gr_complex
Definition:
gr_complex.h:15
gr::random::d_rng
std::mt19937 d_rng
Definition:
random.h:34
api.h
gr
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition:
basic_block.h:29
gr::random::d_integer_dis
std::uniform_int_distribution d_integer_dis
Definition:
random.h:37
gr_complex.h
gr::random::d_seed
long d_seed
Definition:
random.h:30
gr::random::d_uniform
std::uniform_real_distribution< float > d_uniform
Definition:
random.h:36
gr::random::d_gauss_stored
bool d_gauss_stored
Definition:
random.h:31
gnuradio-runtime
include
gnuradio
random.h
Generated by
1.8.17