0

I have a table like this:

IQ       Score   Percentile 
58.75  |   0   |   0
70     |   15  |   2
85     |   35  |   16
100    |   55  |   50
115    |   75  |   84
130    |   95  |   90   

Im trying to find an equation that I can use to dynamically generate with PHP the 'Percentile' value when I know both the IQ and the Score.

This table came from an Excel spreadsheet, it might have been calculated with VLOOK or something like that.

Any ideas on how I could calculate those values?

matt
  • 2,312
  • 5
  • 34
  • 57
  • percentile would be (count where iq < targetiq) / (count of total population) * 100 – Orangepill Jul 23 '13 at 14:53
  • So if IQ = 92.5; Score = 45; what would be the percentile? – matt Jul 23 '13 at 14:59
  • 1
    It would be the number of IQ's < 92.5 / the total number IQ's for percential ... replace IQ with score to get percentile ranking for score. – Orangepill Jul 23 '13 at 15:02
  • Is the table much bigger than you're showing? "Percentile" only makes sense if you have enough data (way more than 6). How are IQ and score related? Is IQ a function of score, and so you just need a percentile of scores? – Teepeemm Jul 23 '13 at 16:26

1 Answers1

0

I think the query you are after is

  SELECT SUM(IF(IQ < $target_id, 1,0)) *100 / COUNT(IQ) from IQ_TABLE;
Orangepill
  • 24,500
  • 3
  • 42
  • 63