Convert lowest number to highest score and highest number to lowest score

1.7k Views Asked by At

I apologise if this is something very basic, but I really struggle with maths!

I am programming a system where the shorter the distance between two locations the higher the score will be out of say a maximum of 10 or even 100. Distances can range from 0 miles to thousands of miles.

I want to derive the score from the actual distance if possible. So for example, a distance of 0 to 10 would = 10 points but a distance of more than > 1000 would = 0 points.

Is there a way to do this and if so how? An explanation of each step would be very much appreciated rather than just a calculation - that way I might learn something!

1

There are 1 best solutions below

0
On

There will be countless ways to achieve this, since the problem is somewhat loosely stated. What I take from your post is that you want:

  • A scoring system $S(x)$ that works for the interval $[0,\infty)$
  • Has score zero on $(1000,\infty)$
  • Has score $10$ on $[1,10]$
  • Decreases monotonically to zero on $(10,1000]$

You have not stated whether the output/image of $S(x)$ must be whole numbers, but if you want to, you can always round off and adjust the details. Some suggestsions could be:

enter image description here

Where $f(x)$ is a linear function through $(1,10)$ and $(1000,0)$ whereas $g$ and $h$ are an exponential function and a power function respectively through $(1,11)$ and $(1000,1)$ then shifted down $1$ in the $y$-direction to land through $(1,10)$ and $(1000,0)$. The reason for doing the $y$-shifting before and after was due to the fact that neither type of function allows for $y=0$ so $(1000,0)$ would be impossible.


Many more shifted exponential functions or power functions will be possible, and yet other functions are possible, so feel free to ask or even to clarify your original post as to point to a more specific well defined solution.