Sample points logarithmically between a a range of y values

54 Views Asked by At

I'm sorry if this a simple question but I couldn't understand the math from example graphs I read online.

Example numbers to make this easier:

Assume x = 0 to k (but let's assume k = 20)

Assume y = 50000 to 1000 (constant, not variable but y = y_0 to y_k, y_0 > y_k)

=> when x = 0 => y = 50000

=> when x = 20 (or k) => y = 1000

I'd like to retrieve the y value points for x = 1, ..., k - 1, such that it is not a linear scale, but a logarithmic one. I'd like values to decrease quickly and then slow down, so something like x = 1 is like 40000, but x = 15 = 2000, x = 16 = 1500, x = 17 = 1350, x = 18 = 1200. I understand that if I multiply the previous value by a constant percentage I will get the result I want, but how do I determine the scale such that the above property will be met for any value x = 0 to k and any value y = y_0 to y_k where y_0 > y_k?

Thanks for any help!

1

There are 1 best solutions below

1
On BEST ANSWER

Suppose we want a curve $y_x=r^xy_0$ that passes through $(x_0, y_0)$ and $(x_k, y_k)$ where $y_0 > y_k > 0$.

In particular, we have $y_k = r^k y_0$.

Then $$r^{k} = \frac{y_k}{y_0}$$

$$r=\left(\frac{y_k}{y_0} \right)^\frac1k$$

Hence $$y=y_0\left( \frac{y_k}{y_0}\right)^\frac{x}{k}.$$