[Math] How to scale numbers from one range to another range

algebra-precalculusdiscrete mathematics

I'm stuck in a problem of mapping numbers from one range to another. I want to calculate popularity of a web page based on the number of page hits on a scale of 10. The problem is total number of web pages are around 41,00,000 and the web pages for which page visit is given are only 1,70,000. Also, the page visit for a web page is between 20,000 and 1.

Now, I'll try to rephrase the above problem in more mathematical problem, I have 41,00,000 objects for which I need to calculate some factor "po". Out of these 41,00,000 objects, 1,70,000 objects contain some number 20,000 <=y <= 1. Now how can I calculate "po" for each object on scale of 10.

The data mostly looks like,

O1: 20,000
O2: 17,000
O3: 16,000
.
.
.
.
.
.
.
O19: 334
O20: 300
.
.
.
.
.
.
.
On: 1 and so on......

Mostly, objects have page visits = 1.

I tried calculating page visit for each object/maximum page visit for an object but that gives me very small values(like 1/20,000 is a very small number). I want my resulatant po values to be at some distance from one another so that I can differentiate between them.

Can anyone please suggest me some solution ?

Thanks

Best Answer

The simplest way to take a range of $[1,20000]$ to $[1,10]$ is to subtract $1$, multiply by $\frac 9{199990}$ and add $1.$ If your division is integer divide, that will collapse many input values to the same output value. With only $10$ output values, there is no preventing that. If your division is floating point, $\frac 1{2000}$ is not small, so you can still see differences.

Related Question