note 108615 deleted from function.stats-stat-correlation by salathe
| From: | salathe@php.net | Date: | Fri, 11 May 2012 08:43:07 +0000 |
| Subject: | note 108615 deleted from function.stats-stat-correlation by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187930@lists.php.net to get a copy of this message | ||
Note Submitter: 4705266 at gmail dot com
----
/***************************************\
â«âªâ«âªâ«â¥âªâ«âªâªâ«Fatih Mehmet DAÄ
â«âªâªâ¥â¥â¥â¥â¥â«âªâª
â«âªâ«â¥âªâªâ«â¥â«âªâª F.M.D.
âªâªâ«â¥âªâªâ«â«âªâ«â«
â«â«âªâ¥â¥â¥â¥â¥âªâ«â«4705266@gmail.com
â«â«âªâ¥â¥â¥â«âªâ«âªâ«
â«âªâ«â¥â«âªâªâ¥âªâ«âªwww.fatihdag.com
â«â«âªâ¥âªâ«âªâ«âªâ«âª
âªâ«âªâ¥â«âªâ«â¥â«âªâ«11-05-2012
00:42:15âªâ«âªâ¥â«âªâ«âªâ«âªâ«
\***************************************/
function getCorrelation($x_array,$y_array){
//CODED by F.M.D
$tx=0;
$ty=0;
$txy=0;
$txx=0;
$tyy=0;
$n=count($x_array);
foreach($x_array as $a=>$b){
$xy[]=$b*$y_array[$a];
$xx[]=$b*$b;
$yy[]=$y_array[$a]*$y_array[$a];
$tx+=$b;
$ty+=$y_array[$a];
$txy+=($b*$y_array[$a]);
$txx+=($b*$b);
$tyy+=($y_array[$a]*$y_array[$a]);
}
return (($n)*($txy)-($tx)*($ty))/sqrt((($n*$txx)-($tx*$tx) )*(($n*$tyy)-($ty*$ty))) ;
}
$x[]=60;
$y[]=3.1;
$x[]=61;
$y[]=3.6;
$x[]=62;
$y[]=3.8;
$x[]=63;
$y[]=4;
$x[]=65;
$y[]=4.1;
$r= getCorrelation($x,$y);
echo "r^2 = $r";
output: r^2 = 0.91187249533773