Sorry I should've followed the "code" rules. Here is my code - thanks!!!
sub func
{
my $x = shift;
return (1/(sqrt($Vz*2*3.1416)+0.000001))*exp(-(($x-$Mz)**2)/((2*($Vz**2))+0.000001));
}
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...
I wrote a C++ program in Dev-C++. I kept having the problem of access violation (segmentation fault) when I was running the program. :( The following was a segment at which the problem probably occurred.
int main(){
ofstream fout("output.txt");
for(int j=0;j<20;j++)
{...
woooow it works now! I tried
sub func
{
# get $x from @_ (passed-in arguments)
my $x = shift;
return $x*2+5;
}
and the result is correct now. Thanks sooo much - really lots of help and favor.
Thanks!
I'm trying to use Eric Boesch's library, Math::Integral::Romberg, for the integral of a Gaussian distribution from 0 to 1. However I have some problems about "a reference to the function to be integrated". In my code, I wrote
$area=integral(\&func, 0, 1);
to do the integration, which is...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.