How to generate perfectly distributed numbers for an arbitrary probability distribution function ?

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

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

Connectez-vous pour commenter.

Réponses (0)

Produits

Version

R2020a

Commenté :

le 7 Oct 2020

Community Treasure Hunt

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

Start Hunting!

Translated by