I'm looking for a function that takes an array of values between a..b (like 0..1) and a central point a < c < b (like 0.5) and a factor (like 2, 3, 4, etc) and pushes all the array's values away from the central point.

For example if we have [0.0, 0.25, 0.48, 0.56, 0.87, 0.98] as input to the function, I'm expecting to get something like [0.0, 0.23, 0.41, 0.65, 0.895, 0.9848]. The factor number should be able to control how much the numbers are stretched away from the central point.

There are some implementation details like how much should the factor affect the stretching that I leave up to you. I just want a pushing function to do something as mentioned above.

If there is a name for these kinds of functions, I'd be glad if you could point me towards that direction.



Try this function, $$f(x)=\frac{c+mk(\frac{c-x}{x-m})}{1+k(\frac{c-x}{x-m})}$$ where $m=a$ if $a<x<c$ and $m=b$ if $c<x<b$.

(This function comes by solving $\frac{c-f(x)}{f(x)-a}=k(\frac{c-x}{x-a})$)

Hope it is helpful:)

  • $\begingroup$ This is really good, the only problem is it has a NaN problem where x = a or x = b. What should I do about it? $\endgroup$ – Cypher Dec 12 '18 at 10:06
  • $\begingroup$ I think a,b and c are not in the domain of the function because the task is to push that number within limits of a & b and pushing a or b will go out of the limits. $\endgroup$ – Martund Dec 12 '18 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.