j4m4l
j4m4l

Reputation: 15

calculate percentile for each entry in the data list

//I have a list of students List<Student>  
Students  
{  
     lond StudentId;  
     double Marks;  
     int Rank;  
    double Percentile;  
}  

I am supplied with Id and Marks, and need to calculate rank and percentile. I searched on methods for calculating percentile but they provide answer in different format like - how to calculate 95th percentile or 5th percentile.

But what i need to calculate is rank and specially percentile for every student and not a specific percentile holder.
thnx in advance...

Upvotes: 0

Views: 1232

Answers (1)

giltanis
giltanis

Reputation: 487

Okay, so you need to first rank/sort all the Students by Mark such that the best grade is the first in the list. Then you can populate the Rank obviously by just counting up.

For the percentile you take (TotalNumberOfStudents - Rank of Student) / (TotalNumberOfStudents - 1)

So in other words, if you are the top ranked student you are better than 100% of the other students and if you are ranked 50 out of a 100 students then you are better than 50% of the students.

Now one wrinkle is that if students can have the same exact grade then they need to not be counted in the Denominator of the formula since that represents the number of students worse than you.

Upvotes: 3

Related Questions