cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to apply a logistic regression equation to classify some new cases. The equation yields rather large numbers for the z value. When I try to convert one of these values to a probability like so (simplified example):
$e winds up with value 1.#INF. I researched this and found that it is a problem with how perl handles large numbers.my $z = -15863.8668285308; my $e = exp($z * -1); my $prob = 1/$e;
So I added use bignum;. This stores $z as type Math::BigFloat, but when I try to get the exp() result, it doesn't return. It's not hanging because I can see from Windows task manager that the interpreter is running, but after minutes it is has still not returned. The calculator on my Windows machine returns the answer in a fraction of a second, so something is clearly not right. What am I doing wrong?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: exp() bignum issue
by Fletch (Bishop) on Aug 30, 2020 at 20:40 UTC | |
by cormanaz (Deacon) on Aug 30, 2020 at 22:42 UTC | |
by syphilis (Archbishop) on Aug 31, 2020 at 00:29 UTC | |
|
Re: exp() bignum issue
by salva (Canon) on Aug 31, 2020 at 13:11 UTC | |
|
Re: exp() bignum issue
by swl (Prior) on Aug 31, 2020 at 03:29 UTC | |
|
Re: exp() bignum issue
by jo37 (Curate) on Aug 30, 2020 at 21:10 UTC |