R – Algorithm for logarithmically converting a number to a percentage


I am looking for a way to convert any number to a percentage in the following way:

  1. 1.00 is 50%

  2. numbers below 1.00 approach 0% logarithmically

  3. numbers above 1.00 approach 100% logarithmically.

    x > 0. So y needs to approach 0 as x becomes infinitely small on the positive side.

I'm sure this is simple to do, but I can't recall how to do it.

Best Solution

try 1 / (1 + e^(1-x))

it's the logistic function shifted by 1 unit


If you want it to approach faster, you can change e to something higher


to have f(0) = 0 you could use 1 - 2^(-x)