471,330 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

C# percentile rank algorithm

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
1 13649
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.

Similar topics

5 posts views Thread by adrianTNT | last post: by
2 posts views Thread by dam_fool_2003 | last post: by
3 posts views Thread by Dave Veeneman | last post: by
13 posts views Thread by Steve Edwards | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.