PDF of a function of a random variable - wrong scale?

2 visualizzazioni (ultimi 30 giorni)
I have a random variable x, which is log-normally distributed with PDF lognpdf(x, 0,psi*sqrt(rho)).
I also have a function of x, Fx which PDF I want to find; I am using the following theorem and code:
x = 0.5:0.01:2; rho = 0.1; psi = 0.1834;
%Function of a random variable
Fx = logncdf(0.7./x,0,psi*sqrt(1 - rho));
%PDF of a function of a random variable
PDF_Fx = lognpdf(x, 0,psi*sqrt(rho)).*abs(gradient(x,Fx));
%PDF reaches 30
plot(Fx,PDF_Fx); set(gca,'XLim',[0 0.095]);
%Integral over pdf gives -1
trapz(Fx,PDF_Fx)
The problem is the scale of the resulting PDF which reaches very high levels of around 30. How can a probability of certain value of a rnd variable be 30? However, when I integrate over the PDF with trapz I get -1 which also doesn't make much sense. Is there something in the transformations that messes up with the scale of the PDF that I am not taking into account?

Risposta accettata

Walter Roberson
Walter Roberson il 20 Nov 2016
The integral of the PDF has to be 1, but the PDF of an interval is multiplied by the width of the interval when doing the integral.
For example, if you took an interval of width 1/30 and you limited the PDF to one, then the integral could not exceed 1 * (1/30) . So the PDF has to be 30 so that the integral would be 30 * (1/30) = 1
So, do not worry about the PDF exceeding 1.
As for the value coming out -1: your Fx values decrease instead of increasing.
trapz(fliplr(Fx),fliplr(PDF_Fx))
  2 Commenti
Konstantin
Konstantin il 20 Nov 2016
So if I want to limit the PDF to 1, then I should divide it by the length of x?
plot(Fx,PDF_Fx./size(x,2));
What about if I have x1 with the same range but bigger grid
x1 = 0.5:0.0001:2;
Then plotting
plot(Fx1,PDF_Fx1./size(x1,2));
would give me different result although that the PDF is the same
Walter Roberson
Walter Roberson il 20 Nov 2016
If you want to limit the PDF to 1, you could divide the values by realmax, or you could divide the values by their max(). However, if you limit a PDF to 1 then it is no longer a Probability Density Function.
Consider a 1 x 1 square of uniform probability
____
| |
|___|
integral of 1 over width 1 is 1, so the total probability is good.
Now squeeze the area to be half as wide
__
| |
|_|
integral of 1 over width 1/2 is 1/2, so the total probability does not work out. But make it twice as high...
__
| |
| |
| |
|_|
integral of 2 over width 1/2 is 1, so the total probability works out.
The PDF corresponds to this 2. If you were to limit it to 1 then your total probability could not possibly work.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by