Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Proportionate redistribution of weights

by CiceroLove (Monk)
on Oct 26, 2004 at 23:02 UTC ( #402835=perlquestion: print w/replies, xml ) Need Help??

CiceroLove has asked for the wisdom of the Perl Monks concerning the following question:

Okay, so I am building an appraisal system that will allow any number of metrics to be included in the appraisal and have any kind of percentage of the overall appraisal score. And those percentages equal 100% prior to scoring. However, a person may rate a metric as not applicable thereby removing the percentage of the not applicable metric from the overall total of 100%. The percentage of the not applicable metric must be proportionately redistributed over the remaining applicable metrics. Example: Assuming a scale of 1 to 5
Metric Weight Score Weighted Score Leadership 40% 2 .8 Punctuality 20% 2 .4 Cleanliness 30% 2 .6 Responsiveness 10% 2 .2 Total 100% 2
However, if we remove one metric entirely by rating it NA then our table looks like this
Metric Weight Score Weighted Score Leadership ?>40% 2 ? Punctuality -- NA -- Cleanliness ?>30% 2 ? Responsiveness ?>10% 2 ? Total 100% 2
How do I proportionately redistribute the 20% across the remaining three metrics to have a total of 100% and all weights are still proportional to the overall score distribution? Thanks for your time and help.


CiceroLove
Fates! We will know your pleasures: That we shall die, we know; 'Tis but the time, and drawing days out, that men stand upon. - Act III,I, Julius Caesar

Replies are listed 'Best First'.
Re: Proportionate redistribution of weights
by tye (Sage) on Oct 26, 2004 at 23:57 UTC

    I'd draw the table more like this

    Metric Weight Percent Score Weighted_score Leadership 40 40% 2 0.8 Punctuality 20 20% 2 0.4 Cleanliness 30 30% 2 0.6 Responsiveness 10 10% 2 0.2 Total 100 100% 2.0

    Then remove one item and you don't have to change any weights, just calculate the new percentages and weighted scores:

    Metric Weight Percent Score Weighted_score Leadership 40 50% 2 1.0 Punctuality -- --% N/A --- Cleanliness 30 37.5% 2 0.75 Responsiveness 10 12.5% 2 0.25 Total 80 100% 2.0

    A percentage is just a type of weight but weights don't have to add up to 100 while percentages do. So dealing in weights that aren't (necessarily) percentages is more flexible and easier to understand when you have a problem like this.

    - tye        

      Precisely the sort of thing I was suggesting, but made more clear. The absolute weights and scores can then be used to calculate percentages and weighted scores. I'd probably list the percentages after the scores, though, unless there's some specific reason that, for viewing purposes, they should be listed first.

      - apotheon
      CopyWrite Chad Perrin
Re: Proportionate redistribution of weights
by ikegami (Pope) on Oct 26, 2004 at 23:48 UTC
    my @metrics = ( # Weights don't need to add up to anything specific. [ 'Leadership', 0.40 ], [ 'Punctuality', 0.20 ], [ 'Cleanliness', 0.30 ], [ 'Responsiveness', 0.10 ], ); my @scores = (2, undef, 2, 2); my $total_weight = 0; foreach (0..$#metrics) { $total_weight += $metrics[$_][1] if (defined($scores[$_])); } my $total = 0; foreach (0..$#metrics) { if (defined($scores[$_])) { my $metric = $metrics[$_][0]; my $score = $scores[$_]; my $weight = $metrics[$_][1] / $total_weight; my $weighted = $score * $weight; $total += $weighted; printf("%-20s %d %5.3f %5.3f$/", $metric, $score, $weight, $weig +hted); } else { my $metric = $metrics[$_][0]; printf("%-20s - ----- -----$/", $metric); } } printf("%-20s - ----- %5.3f$/", 'Total', $total); output ====== Leadership 2 0.500 1.000 Punctuality - ----- ----- Cleanliness 2 0.375 0.750 Responsiveness 2 0.125 0.250 Total - ----- 2.000
Re: Proportionate redistribution of weights
by pg (Canon) on Oct 26, 2004 at 23:11 UTC

    Simple, just distribute that 20% among the rest three according to their ratio 8:6:2. This should result the same as if you re-distribute the original 100% among those 3 according to this same ratio 8:6:2. Either way, the end result would be 50%, 37.5%, 12.5%.

      That's pretty similar to how I see it, though I do it a different way..

      Metric Weight Score Weighted Score Leadership 40% 2 .8 Punctuality 20% 2 .4 Cleanliness 30% 2 .6 Responsiveness 10% 2 .2 Total 100% 2
      Basically, all the weights apply to a total... in this case, it's 100%

      When you eliminate the Punctuality column, you're left with a total of 80%... So just figure out what percentage of 80 the remaining weights are:

      Leadership 40/80 = 50% Cleanliness 30/80 = 37.5% Responsiveness 10/80 = 12.5% Total 80% 100%
      So the recalculated weighted score becomes:
      Metric Weight Score Weighted Score Leadership 50% 2 1 Cleanliness 37.5% 2 .75 Responsiveness 12.5% 2 .25 Total 100% 2
      Trek

      Edit: Added recalculated table.

Re: Proportionate redistribution of weights
by thor (Priest) on Oct 27, 2004 at 00:42 UTC
    The remaining percentages will add up to a certain other percentage. Multiply every number left (raw score as well as percentage) by 100/(sum of remaining percentages). This will give you the new weighted score as well as the percentage of the whole that each represents.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

Re: Proportionate redistribution of weights
by apotheon (Deacon) on Oct 26, 2004 at 23:14 UTC
    quick answer (edited because I misunderstood the goal the first time around):

    The problem is that you need another column with comparative values, if you want your weights to add up to 2. I don't see why you want your weights to add up to 2, though. The whole point of weight is to determine relationships of elements to each other, isn't it?

    So. Let's call the new one "value". The values, in top-to-bottom order, are 4, 2, 3, and 1. Multiply each score by its element's value. Add them all together. That gives you a weighted score for each element, and a weighted total score. Divide weighted element score by weighted total score to get percentage. Multiply decimal value of percentage by 2 to get weights that add up to 2.

    (apologies for sloppy phrasing)

    - apotheon
    CopyWrite Chad Perrin

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://402835]
Approved by ysth
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-06-22 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (110 votes). Check out past polls.

    Notices?