Simple math question: [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this questionI have a simple question.
I have two values MIN and MAX. Then i have a series of values (X) that can be between 0 and +infinity.
Now I want to have an algorithm that maps each value x of X into the range between MIN and MAX.
Here's one that just uses basic arithmetic (no atan
or exp
):
MAX + (MIN − MAX) / (1 + x)
If you need to vary the shape of this conformal mapping, try
MAX + (MIN − MAX) / (1 + f(x))
for any positive function f (for example f(x) = kx or f(x) = √x or ...).
MIN + atan(x)*(MAX-MIN)/(PI/2)
Assuming you want a monotonically increasing function:
MAX + (MIN - MAX)*exp(-k*x)
Where k
is a rate factor that determines how quickly the mapping approaches MAX.
精彩评论