Solved

percentile calculation

Posted on 2004-04-23
5
2,379 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

829 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