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 个评论
Walter Roberson
2020-10-6
I am not clear as to what you are doing, but perhaps https://www.mathworks.com/help/stats/prob.normaldistribution.icdf.html
Jeff Miller
2020-10-7
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
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!