Remove the curve throwers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Remove the curve throwers

Post by neophyte »

I'm trying to calculate a time average. I have a start time and end time. I'm trying to calculate how long it took to take a quiz for a group of quiz takers. The problem is that there are couple people "throwing the curve".
time (in seconds)
1
2
100
300
200
343
233
3400
340000
I would like to programatically remove the "curve throwers" before calculating the average.

How do you do it? Is there a Mysql function I should be using other than avg? Here's my exsisting query.

Code: Select all

"SELECT ROUND(AVG(endtime - starttime) ) AS total FROM respondents"
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Depends on how you want to do the curve?

Some curves remove a top and bottom percentile (Typically 10%) some curves (Olympics I believe) remove the best and worst (as for scoring goes)
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Lets say I want to remove the top and bottom 10%
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

In PHP.

1. Determine how many results there are. (In an array)
2. Multiply total results by .1 and round up the next whole int.
3. Remove the value of number 2 from the front and back of the array of results sorted asc or desc.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

That did it Hawley! Thanks...
Post Reply