Search code examples
interpolationweighted

Weighted interpolation


I thinking on a solution for a while, but I'm kind a poor in math and google couldn't find me any samples.

Given seven values in an array. Each value corresponding to a level of significance as a result of counts. I need to map these values to three color shade levels, like light green, middle green and dark green.

For example:

0  \
5   |
12  |  -> Light green
20 /

76 \  
83  |  -> Middle green
110/ 



142  \ -> Dark green
170  /

Solution

  • Thinking about it on the way home, I think this would work:

    If I take the sorted array's first element and the last one, where both considered to be a 0% and 100% and I calculate the percentage for each value, than a 0-100 range could be mapped to the three color levels.