How to generate perfectly distributed numbers for an arbitrary probability distribution function ?
Afficher commentaires plus anciens
My goal is to create a incremental vector like:
x = linspace(min,max,N);
But the points are distrubuted according to an arbitrary probability distribution function, instead of being evenly spaced.
The only way I can think of is:
x = random('pdf',...,[N 1]);
x = sort(x);
However this is a twisted and nastly method, and only works with a very large N.
The result is still ugly even with N = 1000
x = random('gamma',2,2,[1000 1]);

If I have a perfecly distributed data, instead of random numbers, I only need to sort it to get my incremental vector.
Unfortunaly I only know how to do the opposite: data -> bin -> pdf, which does not work the other way around: pdf -> bin x-> data
Thanks in advance !
2 commentaires
Walter Roberson
le 6 Oct 2020
I am not clear as to what you are doing, but perhaps https://www.mathworks.com/help/stats/prob.normaldistribution.icdf.html
Jeff Miller
le 7 Oct 2020
Like Walter, I think icdf will give the nice even data values that you want. The only trick is to generate the p values for icdf with linspace between 0 and 1, something like
pd = makedist(???); % create the arbitrary distribution that you want to use
p = linspace(0.001,0.999,N); % evenly spaced cumulative p values for your data points
x = icdf(pd,p); % the x values corresponding to those p values
Réponses (0)
Catégories
En savoir plus sur Descriptive Statistics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!