Weighting numbers

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Weighting numbers

Post by s.dot »

This is a bit of a mathematical question, so I thought I would post it here in theory and design.

I'm going to be querying this table and coming up with two numbers.
The first number is going to be total entries cast for each program (by everyone)
The second number is going to be the average number of entries cast by each person per program (they can submit more than one entry).

So I have the following data:

Code: Select all

Total: 1193
Average: 5.97
Now I need to come up with a new number that will be calculated from these numbers. This will be the final weighted score.
The total needs to be 20% of the final score and the average needs to be 80% of the final score.

So 1193 needs to hold 20% weight. The 5.97 needs to hold 80% weight.

My immediate thinking was to do 1193 * (20/100) and 5.97 * (80/100)

But this will just add weighting to each individual number, not to the final score to be calculated.

Any help?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Weighting numbers

Post by Benjamin »

Weighted Average would be:

Code: Select all

 
$weighted_average = round(($total * 0.80) + ($average * 0.20)) / 2, 2);
 
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Weighting numbers

Post by s.dot »

Yeah that's what I thought (as I said in my first post). I thought it seemed weird to weight each individual number, but I guess not. I guess the part I was missing was adding them together and dividing by two. :P
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Weighting numbers

Post by Benjamin »

Yeah, I feel like something is missing but I may be looking too deep. Have a look here:

http://en.wikipedia.org/wiki/Weighted_mean#Example
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: Weighting numbers

Post by Oren »

You guys are definitely looking at it too deep... ( total * 0.2 + avg * 0.8 )
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Weighting numbers

Post by Eran »

You have to consider in what scale do you want the score to be? is it in a 1-10 scale or a 1-1000 scale? in order to compare scores you need to define a scale to compare against.

Obviously 1193 and 5.97 aren't in the same scale - they are two orders of magnitude apart. One is a sum, the other is an average so their units are different (entries and entries / per person). To perform any kind of meaningful math involving the two numbers, they have to be in comparable units (a simple example would be to try adding area units such as squared miles to length units such as inches. It is meaningless)
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Weighting numbers

Post by s.dot »

OK, I guess I should stop using theoretical examples in my posts, LOL.

The real data is from a ranking mechanism. There are about 70 items that can be ranked on a scale of 1-10 (10 being highest). This particular client wants the number of total votes for each item to hold 20% weight and the actual ranking for each item (total points / total votes) to hold 80% weight.

So let's say just *1* particular item had 750 total votes. The average rank for this item was 5.5.

How would I go about weighting this?

I could get the sum of each 750 votes (total points), then I'd have total votes cast and total points accumulated.. but I still don't know if these are the same scale.

EDIT| I think I may be on to something here.

I could take the 15389 votes cast for all the items and divide it by 750 (the votes for this 1 item) and come up with an average of 20.51. Now I have an average along with the average rank of 5.5.

The average of 20.51 would be on a 1/70 scale (it is 1 item out of 70 total items)
The average of 5.5 would be on a 1/10 scale. (it is rated a 5.5 out of 10)

I could multiply each average by the lowest common denominator to be on the same scale, and THEN weight. Does this sound about right?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Weighting numbers

Post by Eran »

Does this sound about right?
Not really, but you were getting close. To weigh an average rank of an item vs all the votes, you have to divide the votes for that item by the total numbers of votes. From your example it would be 750 / 15389 = 0.048 (meaning very close to 5% of the votes). You take this number and multiply it by the scale you have (10). This means if if an item received every vote, it would have scored a perfect 10.

You take the result of the calculation I described and add it as 20% percent of the weighted score along with the other 80% being the average score, so the end result would be :
( (item votes / total votes) * 10 ) * 0.2 + (average rank) * 0.8 = weighted rank

Obviously for an item with only 5% of the votes this won't add much, but items with the lion share of the votes would get a nice boost.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Weighting numbers

Post by s.dot »

Thanks Pytrin. I've got it now. I've defined a 10 point scale, and did the weighting on the scale to get them on the same scales.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply