Inverse Cumulative Distribution Function for a Custom PDF.

20 visualizzazioni (ultimi 30 giorni)
Hello!
I'm looking for a function similar to norminv in wich you can sample data at the probability values in the vector p according to the normal distribution but I need to make it according to a custom probability distribution instead of the normal, always in the vector p but without the use of the original dataset wich generated the custom PDF.
Or in other words a icdf for a custom PDF function....Thanks!

Risposta accettata

Jeff Miller
Jeff Miller il 7 Mar 2020
If you have the custom PDF function (call it custPDF), then you can compute the custom CDF function something like this:
function p = custCDF(x)
p = integral(@custPDF,LowerBound,x); % Modify AbsTol and RelTol to suit your needs
end
where LowerBound is some minimal value for your custom distribution.
Then you should be able to get the inverse CDF with this:
function x = custiCDF(p)
x = fzero( @(x) custCDF(x)-p, [LowerBound,UpperBound] );
end
where UpperBound is a maximal value.
It might be pretty slow, but it should work.
  3 Commenti
Jeff Miller
Jeff Miller il 8 Mar 2020
What vector? A vector of p values for which you want to look up inverses? In that case just use a for loop to call custiCDF for each one.
But maybe I misunderstood your original question. Do you actually only have a sample of data points from which you can estimate the custom PDF? This is different than having a function custPDF that returns PDF values. If that is your situation, I would give a different answer.
Emiliano Rosso
Emiliano Rosso il 8 Mar 2020
No,I misunderstood,I must call custiCDF for each one,
Thanks!

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