I created two functions that output two random variables. I want to output them in the output file. But it does not seem to work.
# Function rgaussian1(r1, r2)
# Gaussian random number generator
function rgaussian1(r1, r2) {
pi = 3.142
v1 = sqrt( -2 * log(rand()) )
v2 = 2 * pi * rand()
r1 = a * sin(b)
r2 = a * cos(b)
}
# Function rgaussian2(r1, r2)
# Gaussian random number generator
function rgaussian2(r1, r2) {
do {
v1 = 2 * rand() - 1
v2 = 2 * rand() - 1
rsq = v1 * v1 + v2 * v2
} while (rsq > 1)
fac = sqrt(-2 * log(rsq) / rsq)
r1 = v2 * fac
r2 = v1 * fac
}
# Include gaussian distributed random numbers
NF == 2 {
rgaussian1(r1, r2)
rgaussian2(r3, r4)
print $0,$2,r1,r2,r3,r4
}