note 100745 added to function.stats-stat-correlation

From: Date: Thu, 04 Nov 2010 07:21:36 +0000
Subject: note 100745 added to function.stats-stat-correlation
Groups: php.notes 
Request: Send a blank email to php-notes+get-173739@lists.php.net to get a copy of this message
I received the undefined function error as well - I guess this belongs to some kind of extension that must be installed. Here is a single function I created to calculate r (Pearson's Correlation Coefficient). Arrays must be equal length. function getPearsons($array_x,$array_y) { if(sizeof($array_x) == sizeof($array_y)) { $n = sizeof($array_x); foreach($array_x as $key=>$val) { //Get the sum of the product of each pair $sum_prod = $sum_prod + ($val * $array_y[$key]); //Get the total of all values in each array $sum_x = $sum_x + $val ; $sum_y = $sum_y + $array_y[$key]; //Get the sum of squares for all values in each array $ss_x = $ss_x + pow($val,2); $ss_y = $ss_y + pow($array_y[$key],2); } $r = $sum_prod - (($sum_x*$sum_y) / $n); $x = $ss_x - (pow($sum_x,2) / $n); $y = $ss_y - (pow($sum_y,2) / $n); $r = $r / sqrt($x*$y); return $r; } } ---- Server IP: 69.147.83.197 Probable Submitter: 111.68.46.235 ---- Manual Page -- http://www.php.net/manual/en/function.stats-stat-correlation.php Edit -- https://master.php.net/note/edit/100745 Del: integrated -- https://master.php.net/note/delete/100745/integrated Del: useless -- https://master.php.net/note/delete/100745/useless Del: bad code -- https://master.php.net/note/delete/100745/bad+code Del: spam -- https://master.php.net/note/delete/100745/spam Del: non-english -- https://master.php.net/note/delete/100745/non-english Del: in docs -- https://master.php.net/note/delete/100745/in+docs Del: other reasons-- https://master.php.net/note/delete/100745 Reject -- https://master.php.net/note/reject/100745 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173739) next »