By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,027 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,027 IT Pros & Developers. It's quick & easy.

C# percentile rank algorithm

P: n/a
Joe
Has anyone written a percentile rank algorithm that they can share or
know of a good resource that defines the algorithm. I'm starting a
project that involves percentile ranks, logistic and linear regression.
If not c# any language or pseudo code would be very useful. Thank you.

Joe

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 30 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Joe wrote:
Has anyone written a percentile rank algorithm that they can share or
know of a good resource that defines the algorithm. I'm starting a
project that involves percentile ranks, logistic and linear regression.
If not c# any language or pseudo code would be very useful. Thank you.

Joe

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com


Forgive me if I'm wrong but isn't percentile rank just counting how many
of the values are below or equal the specific value you're looking at in
terms of percentage of the entire list of values ?

Ie. if you have a value of 50, and there are 75 values in the list, and
30 of those are 50 or below, wouldn't this mean that the percentile rank
of 50 in this list is (30/75)*100 = 40%?

I'd assume sorting the list, then running through it and assigning
percentile ranks would be the best way. You'd have to handle duplicate
values though:

1, 1, 2, 2, 3, 3, 4

would have percentile ranks of:

25%, 25%, 50%, 50%, 75%, 75%, 100%

(if I'm not wrong about what a percentile rank is)

pseudo-code for the above:

- sort list
- loop through all elements from start to finish (lowest to highest)
- find all duplicates of the value you're looking at
- calculate percentile rank as number of values below the value
(index of the loop), plus the number of duplicates, divided by
the number of elements in the list
- skip past duplicates

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Nov 30 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.