I have the following code (where generateGaussian is a function previously defined elsewhere):
function varInstance(stdev, scaling, shift){
gg = -999;
do {
gg = generateGaussian(0, stdev);
}
while (-3 > gg > 3);
return ((gg * scaling) + shift);
}
What I want it to do is to produce a value between -3 and +3 But I notice that occasionally it gives me values >3. I have not not noticed it giving me values <-3, though. What am I doing wrong and how can I change it to limit the output to the -3...3 range?