0

I want to compare two matrices with key = text, value = integer both have the same keys but different values. One value is the relevance and the other is a counter for how often did the key occure. How can i correlate the data and find the most meaningfull keys?

I have lets say 100 words with a relevance factor and a count like these:

$relevance['google'] = 1000;
$relevance['yahoo'] = 1300;   
$count['google'] = 4
$count['yahoo'] = 2

I dont want to see if i have the same arrays. I know that they have the same keys, but different values. I want to normalise the values so that i can compare them and find correlations. So that lets say yahoo is more important than google. Rather then sorting them just by relevance or just by count and looking manual at the data.

Something like normalising the data: having the $relevance values from 0 to 1 with ($val*min)/(max-min) and the same for $count. Afterwards adding both values for count and relevance maybe?

2
  • 3
    can u be more specific?? Dec 5, 2012 at 9:53
  • 1
    Perhaps you should indicate what the end result of this comparison should be. Dec 5, 2012 at 10:02

2 Answers 2

0

well you can use foreach right?

foreach($relevance as $k => $v){
  if($relavance[$k]==$count[$k]){
  //they are equal
  }

}
0

Try array_diff_assoc. If the result is empty you have the same arrays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.