?
Solved

percentile calculation

Posted on 2004-04-23
5
Medium Priority
?
2,386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

764 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