Srishti M
Srishti M

Reputation: 543

Matlab and Mathematica : Finding the density function

The pdf of a standard Gamma distribution is $f(x) = \frac{x^{\gamma-1} \exp(-x)}{\Gamma(\gamma)}$. How do I find the pdf of of the random variable Z = X + Y where Y is the Normal distribution? There is no closed form analytical solution, and it is very difficult to start analytically. SO, was wondering if there is a way to use software tools that will compute the pdf using convolution.

Upvotes: 1

Views: 263

Answers (1)

Nasser
Nasser

Reputation: 13131

How do I find the pdf of of the random variable Z = X + Y where Y is the Normal distribution?

So you must mean X is the Gamma distribution. In Mathematica:

d = TransformedDistribution[x + y, 
   {Distributed[x, GammaDistribution[alpha, beta]], 
   Distributed[y, NormalDistribution[mu, std]]}];
PDF[d, x] // Simplify

gives

 (1/(Sqrt[Pi]*Gamma[alpha]))*((2^(-2 + alpha/2)*beta^(-1 - alpha)*
 std^(-2 + alpha)*             
  (Sqrt[2]*beta*std*Gamma[alpha/2]*Hypergeometric1F1[alpha/2, 1/2, 
  (std^2 + beta*(mu - x))^2/(2*beta^2*std^2)] - 
            2*(std^2 + beta*(mu - x))*Gamma[(1 + alpha)/2]*
        Hypergeometric1F1[(1 + alpha)/2, 3/2, (std^2 + beta
    *(mu - x))^2/(2*beta^2*std^2)]))/
      E^((mu - x)^2/(2*std^2)))

Mathematica graphics

Mean[d]

Mathematica graphics

Variance[d]

Mathematica graphics

Plot for some parameters

 Plot[pdf /. {mu -> 0, std -> 1, alpha -> 1, beta -> 2}, {x, -3, 10}]

Mathematica graphics

Plot[pdf /. {mu -> .5, std -> 2, alpha -> 1, beta -> 5}, {x, -6, 20}]

Mathematica graphics

Upvotes: 2

Related Questions