Solved

percentile calculation

Posted on 2004-04-23
5
2,367 Views
Last Modified: 2013-12-24
Anyone know of an easy way (any way) to calculate percentiles in ColdFusion?

I've a plethora of stats ... from members with easy reach via a MySQL database tables.
I'm looking to perform percentile calculations and cannot see a built-in function in CF or MySQL.

Any ideas!?

for example; ...
I can determine the income level of each and every one of my members.
I'd like to tell a SPECIFIC member which income percentile he fits ... in his specific region of the country (and/or world.

Thanks!
I'm a total CF newbie ... but slowly but surely these tidbits help!
Richard
www.opinion-exchange.com
0
Comment
Question by:rcbuchanan
5 Comments
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 10904863
Well you could use basic math functions,

* / + - < > =
with statements like

<cfswitch>
<cfcase>
<cfif>
<cfscript>

What's an example of what you want to do?
maybe a basic function to post, something that you want to do so you can get a better idea of how to do it?
0
 

Author Comment

by:rcbuchanan
ID: 10904918
ok,
i'll try and describe:

I have a member table with a field called something like 'income' with a $ value.
i.e. member earns $123(k).

I have ... say ... 5,800 members.

I need to tell user # 123 that his income of $123k is in the 97th percentile (for example) of members.

OBVIOUSLY I'd use SQL statement to build a decent / focused selection of credible users ...
BUT ok, math not being my strong point (chased the girls, ignored the classes) ... how do I use CF to calculate!?

Thanks
R
0
 
LVL 18

Expert Comment

by:Plucka
ID: 10905042
Hi rcbuchanan,

You first need to build a list and work out the persons position in the list.

<cfquery name="getList">
    select *
    from member
    order by income
</cfquery>

<cfoutput query="getList">
    <cfif Name eq = "Person Searching">
    <cfset Position = currentRow />
    <cfbreak />
</cfoutput>

<cfset percent = (1 - (Position / getList.RecordCount)) * 100 />

So if they were 5 of one hundred people they are in the 95th precentile.

This is based on order of merrit, not based on salary.

Regards
Plucka
0
 
LVL 18

Accepted Solution

by:
Plucka earned 500 total points
ID: 10905061
rcbuchanan,

oops

<cfset percent = (1 - (Position / getList.RecordCount)) * 100 />

should be

<cfset percent = Position / getList.RecordCount * 100 />

cause i did asc order on the query, so they would appear as say 95/100 being the 95th percentile.

Regards
Plucka
0
 

Expert Comment

by:ErwinMoller
ID: 12663602
Yes, all fine, but how to handle a series of the same numbers?

Consider the following list:

1,2,5,9,12,12,12,12,12,15,21,25

If I score a 12, what is my percentile?
0

Featured Post

Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now