TransWikia.com

PDF of sum of (1/(1+uniform distribution)) and a normal distribution

Mathematica Asked by user13465718 on May 21, 2021

I have a continuous uniform random variable $P∼U(0,1)$ and a normal random variable $X∼N(0,σ)$. If $Z$ is given by $Z=frac{1}{1+P}+X$ where $X$ and $P$ are independent variables, how can I calculate the PDF of $Z$ in Mathematica?

This fails to run:

pdf3 = PDF[
  TransformedDistribution[(1/(1 + z1)) + 
    z2, {z1 [Distributed] UniformDistribution[{0, 1}], 
    z2 [Distributed] NormalDistribution[0, s]}], x]

However, if I look only at $Z = frac{1}{1+P}$ using a similar approach, my code runs OK:

pdf2 = PDF[
  TransformedDistribution[(1/(1 + z1)), {z1 [Distributed] 
     UniformDistribution[{0, 1}]}], x]

One Answer

I know you want an explicit formula for the pdf but I'm not sure that exists. Here's why:

Your pdf2 is

pdf2 = PDF[TransformedDistribution[(1/(1 + z1)), 
  {z1 [Distributed] UniformDistribution[{0, 1}]}], z2]

pdf of 1/(1-p)

So the brute force approach would be to get the pdf of $Z$ as follows:

Integrate[(1/z1^2) PDF[NormalDistribution[0, s], z - z1], {z1, 1/2, 1}, Assumptions -> s > 0]

But the input is just returned and even using Rubi doesn't get an explicit solution. A numerical approach might be what you have to do.

dist = TransformedDistribution[(1/(1 + z1)) + 
    z2, {z1 [Distributed] UniformDistribution[{0, 1}], 
    z2 [Distributed] NormalDistribution[0, s]}];

pdf[z_, s_] := NIntegrate[(1/z2^2) PDF[NormalDistribution[0, s], z - z2], {z2, 1/2, 1}]

s0 = 1/80;
n = 100000;
SeedRandom[12345];
zz = RandomVariate[dist /. s -> s0, n];
Show[Histogram[zz, "FreedmanDiaconis", "PDF"], 
 Plot[pdf[z, s0], {z, 0.4, 1.1}, PlotRange -> All, PlotStyle -> Red]]

Histogram and estimated density

Answered by JimB on May 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP