Formula HYPGEOMDIST returns #NUM!

Topics: Developer Forum, User Forum
Dec 4, 2014 at 8:23 AM
Hi,

i'm trying to obtain the HYPGEOMDIST( 0, 58, 15, 297 ) result but it always returns "#NUM!".
In excel the result it's 0,035151425 and i don't understand why this happens.

Can anyone help, please?

The code is this one:
$objCalc = PHPExcel_Calculation::getInstance();  
 
echo date('H:i:s') . " Create new PHPExcel object" ;
$objPHPExcel = new PHPExcel();

$objPHPExcel->getActiveSheet()->setCellValue('A1', 1)
                              ->setCellValue('A2', 2)
                              ->setCellValue('A3', '=SUM(A1:A2)' );

$aDados = array( 0, 58, 0.05, 297 );
                              
$i      = $aDados[0];
$n      = $aDados[1]; 
$pTxNP  = round( ( $aDados[2] * $aDados[3] ), 0); 
$nP     = $aDados[3];
echo "<br />$i, $n, $pTxNP, $nP ";                              
 
$objPHPExcel->getActiveSheet()->setCellValue('A5', $i )
                              ->setCellValue('A6', $n )
                              ->setCellValue('A7', $pTxNP )
                              ->setCellValue('A8', $nP )
                              ->setCellValue('A9', '=HYPGEOMDIST(A5,A6,A7,A8)' );                             

$objPHPExcel->getActiveSheet()->getCell('A9')->getCalculatedValue() ;

echo '<br />Value HYPGEOMDIST : ' . $objPHPExcel->getActiveSheet()->getCell('A9')->getCalculatedValue() ;   
Thanks, in advance ;)
May 27 at 4:23 PM
Edited May 27 at 5:25 PM
Hi,

i'm here again... can anyone help me with this, please?



I've found that the problem it's in COMBIN and FACT functions...

For example, the result for COMBIN( 245,36 ) it's this little number :)

4668651641378097933263289375402816705068342586410884220805148275449588271075389408443998723926207599208217286397790421324828267392380532445332026022692275335281175820843535645883417421724762145993448159573347940179465650816907080987468542780108873540366818881299561609220578267185642518985522431118537399932794120801761462243319285010314097889653549306260386287686780760973399585824542864162928487905113853694296655053746400236060391941539920891810124518346523728598878464935269246210526945464769910447580976044121540302992307606531952742533162495593568447336682887383354974622899463323599414309983000395772586800721976538111355629980253511750413472407418526617453233267977619224294867620699371365381896771805073708367762875390256742400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000


836 digits!!!

i've used bcmul(), bcdiv() and gmp_fact() but the HypGeomDist() result still not OK :(

Any help??

Thanks in advance!