Jump to content

exp returning zero


dingus

Recommended Posts

ok have have an inverse chi square distribution block

 

that looks like this

 

<?php

function inv-chi2( $x,  $v) {
        $m = (double)$x / 2.0;
        $s = exp(-$m);
        $t = $s;
        
        for($i=1; $i < ($v/2);$i++) {
            $t *= $m/$i;
            $s += $t;
        }
        return ( $s < 1.0) ? $s : 1.0;
    }

?>

 

i know its not perfect butt it worked

 

now ging into that the value of

 

$x = 1895.74465264

and

$v = 2468

 

when we get to the exp function

$m = 947.872326318

 

how ever after exp(-$m);

 

$s becomes zero

 

anyone have any ideas there?

Link to comment
https://forums.phpfreaks.com/topic/102761-exp-returning-zero/#findComment-526720
Share on other sites

If i made the right calculations, the result of exp(-$m) where $m = 1895.74465264 / 2 is ~ 2.19e412, but from the manual:

 

The size of a float is platform-dependent, although a maximum of ~1.8e308 with a precision of roughly 14 decimal digits is a common value (the 64 bit IEEE format).

 

Guess thats why ure getting 0 as a result.

Link to comment
https://forums.phpfreaks.com/topic/102761-exp-returning-zero/#findComment-526731
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.