# How to plot this pdf

Let $$x\sim N(\mu,\sigma^2)$$ and $$y=\max\{e^{x-1}-\kappa,0\}$$. How to get and plot the pdf of y? In particular, there will be a probability mass at $$y=0$$, which is a nondifferentiable point. I tried

pdfY[y_] := \[Piecewise] {
{1/(y + κ) f[Log[y + κ] + 1], y > 0},
{N[Integrate[f[x], {x, -10, Log[κ] + 1}]], y = 0},
{0, y < 0}
}


but it does not work well.

• You'll need to provide values for all of the parameters: $\mu$, $\sigma$, and $\kappa$. – JimB Oct 8 '20 at 3:51
• They can be $\mu=\sigma=1$, $\kappa=3$, for instance. – David Xiaoyu Xu Oct 8 '20 at 4:53
• The PDF can be defined for absolutely continuous random variables only. – user64494 Oct 9 '20 at 5:52
• There will be a probability mass at $y=0$. It is neither PDF nor PMF? – David Xiaoyu Xu Oct 9 '20 at 13:41
• Based on your question and the reasonable challenges by @user64494, I went and asked a similar question at stats.stackexchange.com/questions/491443/…. I think the answer there says that your "pdf" is neither fish nor fowl but that it is a something that can be plotted. – JimB Oct 12 '20 at 3:32

TransformedDistribution[Max[E^(x-1)-κ,0],x\[Distributed] NormalDistribution[μ,σ]]//PDF[#,y]&

1/2 DiracDelta[y+κ] (1+Erf[(1-μ+Log[y+κ])/(Sqrt σ)]) (-1+UnitStep[-y]) (UnitStep[-y] (-1+UnitStep[-κ])-UnitStep[-κ])-DiracDelta[y] (1+Erf[(1-μ+Log[κ])/(Sqrt σ)]) (-1+UnitStep[-κ])-(E^(-((1-μ+Log[y+κ])^2/(2 σ^2))) (-1+UnitStep[-y]) (1+UnitStep[-y] (-1+UnitStep[-y-κ]) (-1+UnitStep[-κ])-UnitStep[-y-κ] UnitStep[-κ]))/(Sqrt[2 π] (y+κ) σ)

• In this case it's simpler to plot the CDF as it is defined everywhere. However, there's no reason not to plot the PDF where the random variable is continuous. In this case one would likely put a dot maybe at (0,0) and note that there's a probability mass of $\frac{1}{2} \left(\text{erf}\left(\frac{\log (\kappa )-\mu +1}{\sqrt{2} \sigma }\right)+1\right)$ at $y=0$ where $\kappa>0$. – JimB Oct 9 '20 at 4:42
• Sorry, I was way too loose with my words. The PDF will exist at any point where the CDF is differentiable. And the PDF does not have to exist at every point to disallow the plotting of the PDF at the points where it does exist. In the OP's example, suppose the $\kappa$ is very small resulting in a very small probability mass at 0 but plotting the PDF where the PDF exists will still give an appropriate picture of the distribution of that random variable. However, I am unaware of a standard way to display the probability mass in such a situation other than including an explanatory note. – JimB Oct 9 '20 at 16:23