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 で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!