GRASS Programmer's Manual
6.5.svn(2014)-r66266
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
gauss.c
Go to the documentation of this file.
1
#include <math.h>
2
#include <grass/gmath.h>
3
4
17
double
G_math_rand_gauss
(
const
int
seed,
const
double
sigma)
18
{
19
double
x,
y
, r2;
20
21
do
{
22
/* choose x,y in uniform square (-1,-1) to (+1,+1) */
23
x = -1 + 2 *
G_math_rand
(seed);
24
y = -1 + 2 *
G_math_rand
(seed);
25
26
/* see if it is in the unit circle */
27
r2 = x * x + y *
y
;
28
}
29
while
(r2 > 1.0 || r2 == 0);
30
31
/* Box-Muller transform */
32
return
sigma * y * sqrt(-2.0 *
log
(r2) / r2);
33
}
G_math_rand_gauss
double G_math_rand_gauss(const int seed, const double sigma)
Definition:
gauss.c:17
y
int y
Definition:
plot.c:34
wxnviz.log
log
Definition:
wxnviz.py:54
G_math_rand
float G_math_rand(int seed)
Random Number Generator (Uniform)
Definition:
rand1.c:17
lib
gmath
gauss.c
Generated on Sat Jan 2 2016 01:46:47 for GRASS Programmer's Manual by
1.8.5