GRASS GIS 8 Programmer's Manual
8.5.0dev(2025)-eb16a2cfc9
Main Page
Related Pages
Data Structures
Data Structures
Class Hierarchy
Data Fields
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
x
y
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
o
p
r
s
t
u
v
w
y
Enumerations
a
c
d
e
h
i
j
l
m
n
o
p
r
s
t
v
y
Enumerator
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
y
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
gauss.c
Go to the documentation of this file.
1
#include <math.h>
2
#include <
grass/gmath.h
>
3
4
/*!
5
* \fn double G_math_rand_gauss(const int seed, const double sigma)
6
*
7
* \brief Gaussian random number generator
8
*
9
* Gaussian random number generator (mean = 0.0)
10
*
11
* \param[in] seed
12
& \param[in] sigma
13
* \return double
14
*/
15
16
double
G_math_rand_gauss
(
double
sigma)
17
{
18
double
x
, y, r2;
19
20
do
{
21
/* choose x,y in uniform square (-1,-1) to (+1,+1) */
22
x
= -1 + 2 *
G_math_rand
();
23
y = -1 + 2 *
G_math_rand
();
24
25
/* see if it is in the unit circle */
26
r2 =
x
*
x
+ y * y;
27
}
while
(r2 > 1.0 || r2 == 0);
28
29
/* Box-Muller transform */
30
return
sigma * y * sqrt(-2.0 * log(r2) / r2);
31
}
G_math_rand
float G_math_rand(void)
Definition:
rand1.c:16
G_math_rand_gauss
double G_math_rand_gauss(double sigma)
Definition:
gauss.c:16
gmath.h
x
#define x
lib
gmath
gauss.c
Generated on Wed May 28 2025 07:03:33 for GRASS GIS 8 Programmer's Manual by
1.9.1