# how can I scale a value beween 0 and 1? [closed]

I have written some AI software that calculates the behavior of the user. If the user behaves well, then the system will increase the user score by $$a$$. If the user behaves badly, the software subtracts $$a$$ from the score. In the end, the software will produce a number (let's say $$X$$): $$X$$ is a sum of values that are the weights to my AI mechanism (sum of good and bad behavior weights).

Imagine I had 750 requests in total and my sum is equivalent to 566 (some requests have a negative weight to cancel the positives).

I need to scale this $$X$$ value between 0 and 1 to see, for example, if $$X$$ falls below a certain defined threshold (e.g. 0.3) then the system assumes a bad user. I have a problem with this statistic how to scale my number between 0 and 1.

• If you really need to scale the values just to say that <0.5 is a failure, why not just use median as a threshold?
– Tim
May 15, 2021 at 12:36
• thanks! not actually that 0.5 threshold was just an example, it can be 0.3 or any other values per user request. May 15, 2021 at 12:38
• Still, it's just a number. There's nothing magical about a number being in the [0, 1] interval. If you need it only for setting thresholds, than why not set them using the actual values?
– Tim
May 15, 2021 at 12:41
• Thanks, Tim, I would be grateful if you can give me an example of this. my problem is for example if my total value added to a number (i.e. 235) how can scale this in the range of 0 to 1? May 15, 2021 at 12:45
• Scaling between 0 and 1 and comparing with a threshold seem quite different calculations. I can't follow what the problem is here. May 15, 2021 at 12:53

One way is to add the theoretical minimun value of your score to each score of the 750 scores you have (so in this case -750 is your theoretical minimum if min(a)=-1). It makes all values positive. Then devide all of the shifted scores to the total number of values. That scales your scores to [0 1] with 0.5 as your new neutral point. Alternatively you can use min-max normalization, but it doesn't guarantee that 0 will be 0.5 in the new scale as max and min values are not necessarily symmetrical for every sample. This is the min-max formula from Wikipedia:

you subtract the minimum value, which will make the minimum to be 0, and then divide by the maximum value, which will make the maximum to be 1.

• what are the minimum and max values?! there is no min and max, it can be anything. it can go to infinite depends on the total requests. May 15, 2021 at 12:41
• @Mob2050 if you don't know min and max, how would you know what should be 0 and what should be 1?
– Tim
May 15, 2021 at 12:43
• you are right, can I relate the min and max somehow to the total number of the request? that is known. the value of the min can be zero but there is no max. because the max will change according to the total requests. as the requests go up the max will change accordingly. May 15, 2021 at 12:52

I would just divide the sum by the maximum possible score.

If each request had a max positive score of +1 then their cumulative score would be: 566/750 = 0.7546666....

If the max score was +2 566/1500 = 0.377333...

If +3 566/2250 = 0.251555...

And so on.

Then you could rank users based on this number, but keep in mind that volume of requests wouldn't be taken into account if you just used this.