PDF of a log-normally distributed variable after tangens hyperbolicus transformation Assume a variable $x_0>0$ with log-normally distributed noise, such that the observation $x$ of $x_0$ has the following PDF:
$$
p(x\mid x_0) = \frac{1}{\sqrt{2\pi}\sigma x}e^{-\frac{\left(\ln{(\frac{x}{x_0})} - \sigma^2\right)^2}{2\sigma^2}}
$$
(NB: $x_0$ thus corresponds to the mode of the log-normal distribution, following the reparameterization $\mathrm{mode}=e^{\mu-\sigma^2}$)
As it turns out, I cannot measure $x$ directly, but only a transformation $y(x)$:
$$
y(x) = (1-\delta)\tanh(\beta x) + \delta
$$
The parameters $\delta$ and $\beta$ are not relevant to my question, but it can be assumed $0\le\delta\le1$ and $\beta>0$.
Now I have a measurement $y_m$ and I want to compute the probability that a latent variable $x_0$ would generate a $y$ within the window $[y_m-\epsilon; y_m+\epsilon]$.
I have two questions related to this:

*

*What is the PDF for $y$ that would allow me to compute this probability? (Note that for reasons not mentioned here, I want to avoid transforming $y_m$ to $x$-space)

*More pragmatically, the scientific programming module I am using (scipy.stats.lognorm) has CDF implementations for the log-normal distribution. If instead of the above $\tanh$ transformation I had the identity transformation $y(x)=x$, I could simply use something along the lines of lognorm(x0,σ).cdf(y_m+ε) - lognorm(x0,σ).cdf(y_m-ε). Can I still use this lognorm CDF implementation after some appropriate transformation?

 A: The hyperbolic tangent function $\tanh$ is a strictly increasing function, so it is quite simple to get the CDF of the random variable $Y$.  I am going to give a more general answer that what you are looking for --- specifically, I will not make any assumption about the distribution $X$, and I will not assume that this is a non-negative random variable.  Using the stipulated transformation with $\beta$ and $0 \leqslant \delta < 1$ you have:
$$\begin{align}
F_Y(y) &\equiv \mathbb{P}(Y \leqslant y) \\[12pt]
&= \mathbb{P}((1-\delta) \tanh (\beta X) + \delta \leqslant y) \\[6pt]
&= \mathbb{P} \bigg( \tanh (\beta X) \leqslant \frac{y-\delta}{1-\delta} \bigg) \\[6pt]
&= \mathbb{P} \bigg( \frac{e^{2 \beta X}-1}{e^{2 \beta X}+1} \leqslant \frac{y-\delta}{1-\delta} \bigg) \\[6pt]
&= \mathbb{P} \bigg( e^{2 \beta X}-1 \leqslant \frac{y-\delta}{1-\delta} \cdot (e^{2 \beta X}+1) \bigg) \\[6pt]
&= \mathbb{P} \bigg( e^{2 \beta X} \cdot \frac{1-y}{1-\delta} \leqslant 1 + \frac{y-\delta}{1-\delta} \bigg) \\[6pt]
&= \mathbb{P} \bigg( e^{2 \beta X} \cdot \frac{1-y}{1-\delta} \leqslant \frac{1+y-2\delta}{1-\delta} \bigg) \\[6pt]
&= \mathbb{P} \bigg( e^{2 \beta X} \cdot (1-y) \leqslant (1+y-2\delta) \bigg). \\[6pt]
\end{align}$$
Taking account of the limits of the function you then have:
$$\begin{align}
F_Y(y)
&= \begin{cases}
0 & & \text{if } y \leqslant 2\delta-1, \\[6pt]
F_X \bigg( \frac{1}{2 \beta} \cdot \log \Big( \frac{1+y-2\delta}{1-y} \Big) \bigg) & & \text{if } 2\delta-1 < y < 1, \\[6pt]
1 & & \text{if } y \geqslant 1, \\[6pt]
\end{cases} \\[6pt]
\end{align}$$
It is easily shown that:
$$\begin{align}
\frac{d}{dy} \log \Big( \frac{1+y-2\delta}{1-y} \Big) 
&= \frac{1}{1+y-2\delta} + \frac{1}{1-y} \\[6pt]
&= \frac{(1-y)+(1+y-2\delta)}{(1+y-2\delta)(1-y)} \\[6pt]
&= \frac{2(1-\delta)}{(1+y-2\delta)(1-y)}. \\[6pt]
\end{align}$$
Therefore, differentiating the CDF with respect to $y$ gives the corresponding density:
$$f_Y(y) = \frac{(1-\delta)}{(1+y-2\delta)(1-y) \beta} \cdot 
f_X \bigg( \frac{1}{2 \beta} \cdot \log \Big( \frac{1+y-2\delta}{1-y} \Big) \bigg)
\quad \quad \text{for } 2\delta-1 < y < 1.$$
Substitution of the density function for $X$ will give you the final form.  Note that in your problem you have assumed that $X$ is a non-negative random variable, which leads to the effective bound $y \geqslant \delta$.  This bound emerges correctly from substitution into the above equation in the case where $f_X$ has support only over positive argument values.
