计算数据列表中每个条目的百分位
//I have a list of students List<Student>
Students
{
lond StudentId;
double Marks;
int Rank;
double Percentile;
}
我获得了 ID 和分数,需要计算排名和百分位。 我搜索了计算百分位数的方法,但它们提供了不同格式的答案,例如 - 如何计算第 95 个百分位数或第 5 个百分位数。
但我需要计算的是每个学生的排名和特别的百分位数,而不是特定的百分位数持有者。
提前谢谢...
//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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,所以您需要首先按马克对所有学生进行排名/排序,以便最好的成绩位于列表中的第一位。然后你可以通过计数来明显地填充排名。
对于百分位数,您采用
(TotalNumberOfStudents - 学生排名) / (TotalNumberOfStudents - 1)
因此,换句话说,如果您是排名最高的学生,您就比 100% 的其他学生更好,并且如果您在 100 名学生中排名第 50,那么你比 50% 的学生更好。
现在的一个问题是,如果学生可以有相同的精确成绩,那么他们就不需要计入公式的分母,因为这代表了比你差的学生数量。
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.