# Calculate a score based on a range of values

I need to convert values to a score in points. Values can range from 0 to 15000.

What formula should I use to calculate the following?

• Any value between 0 and 50 should get the maximum score of 1000.
• Any value equal or greater than 3000 should get the minimum score of 0.
• A value of 51 should be 999 points.
• A value of 2999 should be 1 point.

The score should be an integer in the range of 0 to 1000, based on the value. Obviously, multiple different values will produce the same score.

I did some research but I am not even sure how to call what I am searching for and therefore haven't found any useful info so far.

• Would not a piecewise defined function work?. Also there is a lot of ambiguity on how the score should be calculated in the range $52\leq x \leq 2998$ as for example $$\text{Score}(x)=\begin{cases}1000, &0\leq x \leq 50\\ 999, & x=51\\ 1, &x=2999 \\ 0, &3000\leq x\leq 15000\\ 40, &52\leq x \leq 2998\end{cases}$$ satisfies your written requirements but I doubt it is what you want.
– user649348
Aug 18, 2020 at 12:37

You could do this: $$s = \lceil 999 - \frac{999}{2949}(v-51) \rceil$$
where the $$\lceil \ \rceil$$ means you round the result upwards to the next integer. If the result is larger than $$1000$$, you change it to $$1000$$, and similarly you replace any score below $$0$$ by $$0$$.
For example, $$v=50$$ gives $$s=\lceil 999+\frac{999}{2949}\rceil = 1000$$, and $$v=51$$ gives $$s=\lceil 999\rceil = 999$$ where no rounding needed.
On the other end, $$v=3000$$ gives $$s=\lceil 999-\frac{999}{2949}2949\rceil = \lceil 0 \rceil = 0$$ exactly, while $$v=2999$$ gives a score of $$s=\lceil 999-\frac{999}{2949}2948\rceil = \lceil 0.338 \rceil = 1$$.