Skip to content
Advertisement

Algorithm to show how far away a value is from another

Disclaimer: This is a very very difficult question about mathematics and algorithms (in my opinion) – so respect to anyone who makes this. I admire you.

I would like to evaluate the performance of my employees. I would like to do this by measuring the following parameters as percentages of the amount of time they spend working:

JavaScript

I have a “preferred” set of percentages for each of these. This represents the ideal time that I would LIKE my employees to spend their time.

JavaScript

So in words, I would like my employees to spend 30% of their time in meetings, 10% time travelling and 60% on a desk working.

I would ALSO like to add weights to these different percentages. The weight would represent how “lenient” I am with each percentage being different to what I desire. In other words, how important I find it for each variable to be closest to the desired percentages (30, 10, 60). I would like to apply the weights on a scale of.1 to 10, 10 being most important, 1 being least important.

JavaScript

So given the percentage of time spent by an employee, and the weight of the importance of the time spent being close to the desired time spent, I would like to generate an index between 0 and 100 where 100 is the perfect time percentages and 0 is the worst. So a score of 100 would give the “preferred” percentages:

JavaScript

How I would try to approach this:

  1. Find out what the minimum and maximum ratios are
  2. Calculate a value to tell how far away each value is from the desired value using the minimum and maximum ratios. Make sure this value is in the ratio 0-1 (corresponding to 0-100)
  3. Calculate a weighted average.

Advertisement

Answer

I think you’re trying something which is kinda like the H-score. H-score is a scored we use in digital pathology to measure tumor positivity for a maker and it is meant to weight the number of positive cells by their intensity. It’s:

JavaScript

You could calculate the same as:

JavaScript

Don’t forget to use absolute value when you compute the difference. I used 1-% so that a difference of 0.8 (as planned 0.ì and worked 0.9) will result in a score of 0.2. This will work for the opposite situation too (planned 0.9 and worked 0.1). In this way, who perfectly matches the planned hourse will have a score of 1700%. Then just:

JavaScript
Advertisement