goodluckmich
MIS
In my Perl code I aim to compute the Gaussian integral, and the Gaussian function is expressed as
###code###
sub func
{
my $x = shift;
return (1/(sqrt($Vz*2*3.1416)+0.000001))*exp(-(($x-$Mz)**2)/((2*($Vz**2))+0.000001));
}
###code###
, where I integral from 0 to 1, and $Vz is the variance and $Mz is the mean. 0.000001 is used to avoid the illegal division by zero. However my script will just stop at some point during execution and not proceed anymore. I tried to debug, and figured out it "seemed" to be the problem of the part "exp(...)", because if I replaced the exp() with an arbitrary constant, say 1.5, the script would just work well. However I just didn't get what's wrong with the exp(...) code. It seemed pretty correct to me. Could anyone please help me on this? Thank you very much!!!
###code###
sub func
{
my $x = shift;
return (1/(sqrt($Vz*2*3.1416)+0.000001))*exp(-(($x-$Mz)**2)/((2*($Vz**2))+0.000001));
}
###code###
, where I integral from 0 to 1, and $Vz is the variance and $Mz is the mean. 0.000001 is used to avoid the illegal division by zero. However my script will just stop at some point during execution and not proceed anymore. I tried to debug, and figured out it "seemed" to be the problem of the part "exp(...)", because if I replaced the exp() with an arbitrary constant, say 1.5, the script would just work well. However I just didn't get what's wrong with the exp(...) code. It seemed pretty correct to me. Could anyone please help me on this? Thank you very much!!!