Solved

percentile calculation

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Server with multiple sites and SSL 14 66
URL redirect 4 57
DNS, website, godaddy 6 86
Ubuntu Apache Webserver - File Permissions 5 42
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

823 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