ollie dunn
ollie dunn

Reputation: 315

nonlinear map from one range to another

I have a maths problem I am somewhat stumped on. I need to map a numbers from one range to another in a nonlinear fashion. I have manually taken some sample data from what I am trying to achieve. That looks as such.

source - desired result

0 - 1

78 - 0.885

363 - 0.625

1429 - 0.3

3404 - 0.155

7524 - 0.075

11604 - 0.05

The source number ranges from 0 to, ideally an infinite number, but happy if it stops somewhere in the 10s of thousands. The resultant number is from 1 to 0. It needs to drop off quickly then level off. Ideally never reaching zero.

I am aware of the standard equation to map from one range to another.

y = ((x * origRange) / newRange) + newRangeOffset

Unfortunately this does not give me the desired results. Is there a elegant nonlinear equation that would give me the results I am after?

Upvotes: 2

Views: 3540

Answers (2)

phyrox
phyrox

Reputation: 2449

As suggested here, you can use a polynomial interpolation (present in multiple software packages).

If you want to try it, I suggest you to go to Wolfram Alpha and select the Polynomial Interpolation.

This is one example using some of your points.

Upvotes: 2

perfectionist
perfectionist

Reputation: 4346

f(x) = 620 / (620 + x) gives an answer accurate to within 2% of all your values

Upvotes: 3

Related Questions