Jump to content

bcmul issues


dingus

Recommended Posts

If you were to post an example of what the data and results look like and your code, someone could directly help.

 

Perhaps your existing code just needs to be optimized for execution speed, but we cannot tell without seeing it.

 

Perhaps for the range of values, a different method could be used, but we cannot tell without seeing what your values and results look like.

Link to comment
https://forums.phpfreaks.com/topic/108329-bcmul-issues/#findComment-555384
Share on other sites

ok i'm dealing with a chi2 function which loops like this

 

<?php

function chi2Q( $x,  $v) {
        bcscale(0);
        $m = bcdiv($x , '2.0');
        bcscale(ceil(bcmul('0.8686' , $m)));
        $s = bcdiv('1' , bcpow('2.718282', $m));
        $t = $s;
        $k = ceil(bcdiv($v,2));
        for($i=1; $i < $k;$i++) {
            $p = bcdiv($m,$i);
            //$p = $m/$i;
            $t = bcmul($t, $p);
            //$t = $t*$p;
            $s = bcadd($s,$t);
            //$s = $s+$t;

        }

        return $s ;
}
?>    

 

where $x is the value and $v is the degrees of freedom

 

now the issue exists at this line $t = bcmul($t, $p);

 

as you can see i initially used conventional maths to speed up the process how ever i was getting arithmetic underflow problems which lead me to bc maths

 

i'm deliberately setting bcscale to the minimum number of dec places i will need to optimize as best i can

 

anyone with any suggestions on how to improve this i would greatly appropriated it

Link to comment
https://forums.phpfreaks.com/topic/108329-bcmul-issues/#findComment-555390
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.