note 116529 added to function.stats-stat-correlation
| From: | nonatdotcom | Date: | Mon, 19 Jan 2015 11:30:42 +0000 |
| Subject: | note 116529 added to function.stats-stat-correlation | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201455@lists.php.net to get a copy of this message | ||
undefined for me, thus I've implemented my own correlation which is much faster and simpler
than the one provided above.
function Corr($x, $y){
$length= count($x);
$mean1=array_sum($x) / $length;
$mean2=array_sum($y) / $length;
$a=0;
$b=0;
$axb=0;
$a2=0;
$b2=0;
for($i=0;$i<$length;$i++)
{
$a=$x[$i]-$mean1;
$b=$y[$i]-$mean2;
$axb=$axb+($a*$b);
$a2=$a2+ pow($a,2);
$b2=$b2+ pow($b,2);
}
$corr= $axb / sqrt($a2*$b2);
return $corr;
}
----
Server IP: 72.52.91.14
Probable Submitter: 212.26.44.101
----
Manual Page -- http://php.net/manual/en/function.stats-stat-correlation.php
Edit -- https://master.php.net/note/edit/116529
Del: integrated -- https://master.php.net/note/delete/116529/integrated
Del: useless -- https://master.php.net/note/delete/116529/useless
Del: bad code -- https://master.php.net/note/delete/116529/bad+code
Del: spam -- https://master.php.net/note/delete/116529/spam
Del: non-english -- https://master.php.net/note/delete/116529/non-english
Del: in docs -- https://master.php.net/note/delete/116529/in+docs
Del: other reasons-- https://master.php.net/note/delete/116529
Reject -- https://master.php.net/note/reject/116529
Search -- https://master.php.net/manage/user-notes.php