Greetings fellow monks. I hope you are all surviving the Apocalypse ok.

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):

my $z = -15863.8668285308; my $e = exp($z * -1); my $prob = 1/$e;
$e winds up with value 1.#INF. I researched this and found that it is a problem with how perl handles large numbers.

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?


In reply to exp() bignum issue by cormanaz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.