0
$\begingroup$

I'm dealing with samples with values in $[0,1]$. I'd like to display them on a semi log scale, since the values between $0$ and $0.5$ are more interesting, than $0.5$ and above. Precision is 32 bit float.

I can't figure how to map them on a log scale, where the x-axis is the sample number, and the y-axis the value, on a logarithmic scale. Or rather, how to map a log scale onto regular 2D space, since I'll be painting the points on the graph myself.

To clarify: let's assume the output display is 100 pixels in height, value $0$ would be painted on pixel 0, a value of $0.1$ on pixel 50 and a value of $1.0$ on pixel 99.

I kinda have had this knot in my brain for the entire day, and I can'f figure out how to map those values, since $\log_{10} 0 = -\infty$ and $\log_{10} 1 = 0$.

I feel like it's a very simple question, but I'm just can't find an answer, especially, since the values I need to display are $0.0$ to $1.0$.

The function I'm looking for, should ideally also map into $[0,1]$, so I can scale for the actual output display, etc.

So: $f(0) = 0; \; f(0.1) = 0.5; \; f(1.0) = 1.0$ .

Thanks in advance!

$\endgroup$
5
  • $\begingroup$ @PeterForeman wow, I wasn't expecting it to be that complicated! where do you got the equation for $a$ from, if you don't mind me asking? $\endgroup$
    – polemon
    Jul 13, 2019 at 13:24
  • $\begingroup$ @PeterForeman solving for $x$ in Wolfram Alpha gives the exact equation of $\frac{1}{\log 81}$ which is actually pretty nice. $\endgroup$
    – polemon
    Jul 13, 2019 at 14:14
  • $\begingroup$ How would I go adding another constraint? $f(0.01) = 0.25$, i.e. the solution above placed the distance further down (0.133757), which isn't really $\log_10$-like, if you catch my drift. Is that even possible? $\endgroup$
    – polemon
    Jul 13, 2019 at 18:39
  • $\begingroup$ Through trial and error I arrived at $f(x) = x^{\log_{10} 2}$ it seems suspiciously fitting for my use case, would that be a correct $\log$ function? $\endgroup$
    – polemon
    Jul 13, 2019 at 22:26
  • $\begingroup$ That would provide a polynomial scale and not a logarithmic scale. But you can use whatever scale you want. $\endgroup$ Jul 13, 2019 at 23:25

1 Answer 1

0
$\begingroup$

You could simply plot the pairs $(x_i, f(y_i))$ with $f(y_i) = \frac{1}{2} \log_{10}(y_i) + 1$ instead of the original datapoints $(x_i, y_i)$, couldn't you? This would give $f(1) = 1$, $f(0.1) = 0.5$ and $f(0.01) = 0$. As you point out, mapping $0 \rightarrow 0$ in such a fashion is impossible. If your're set on a logarithmic scale, you will never be able to include 0 in it.

$\endgroup$

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.