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.

  • $\begingroup$ You'll need to provide values for all of the parameters: $\mu$, $\sigma$, and $\kappa$. $\endgroup$ – JimB Oct 8 '20 at 3:51
  • 1
    $\begingroup$ They can be $\mu=\sigma=1$, $\kappa=3$, for instance. $\endgroup$ – David Xiaoyu Xu Oct 8 '20 at 4:53
  • $\begingroup$ The PDF can be defined for absolutely continuous random variables only. $\endgroup$ – user64494 Oct 9 '20 at 5:52
  • $\begingroup$ There will be a probability mass at $y=0$. It is neither PDF nor PMF? $\endgroup$ – David Xiaoyu Xu Oct 9 '20 at 13:41
  • $\begingroup$ 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. $\endgroup$ – 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[2] σ)]) (-1+UnitStep[-y]) (UnitStep[-y] (-1+UnitStep[-κ])-UnitStep[-κ])-DiracDelta[y] (1+Erf[(1-μ+Log[κ])/(Sqrt[2] σ)]) (-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+κ) σ)

then you can plot it.

  • $\begingroup$ This result makes no sense in traditional math since the integral for CDF through PDF makes no sense. The PDF exists only for absolutely continuous distributions (see encyclopediaofmath.org/wiki/Continuous_distribution and en.wikipedia.org/wiki/Probability_density_function ). Such approach leads to bugs e.g. as in mapleprimes.com/posts/207769-Bug-In-Probability. In order to calculate the mean and so on the Riemann-Stielttjes integral is used. $\endgroup$ – user64494 Oct 8 '20 at 23:40
  • $\begingroup$ 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$. $\endgroup$ – JimB Oct 9 '20 at 4:42
  • $\begingroup$ @JimB: Can you ground "However, there's no reason not to plot the PDF where the random variable is continuous"? I prefer arguments over empty words. $\endgroup$ – user64494 Oct 9 '20 at 5:22
  • $\begingroup$ 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. $\endgroup$ – JimB Oct 9 '20 at 16:23
  • $\begingroup$ I was wondering how is the "density function" defined in such cases where there is a probability mass at a point and the CDF is differentiable at other points? $\endgroup$ – David Xiaoyu Xu Oct 11 '20 at 4:26

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.