How to generate a random sequence with some specific probability

How to generate a random sequence with some specific probability except the randn for normal and rand for uniform distribution?

回答 (2 件)

Image Analyst
Image Analyst 2018 年 2 月 22 日

0 投票

Here are a ton of them:
Is the one you want in that list? If not, you'll have to use inverse transform sampling, like my attached example, and described here in Wikipedia.
Walter Roberson
Walter Roberson 2018 年 2 月 22 日

0 投票

If you want to sample unequally from a specific list of values, then use randsample() and use the W (weight) parameter.

2 件のコメント

Huiwen Wu
Huiwen Wu 2018 年 2 月 22 日
Thank you! Can I define a probability distribution by myself? Not the one in the list.
Walter Roberson
Walter Roberson 2018 年 2 月 23 日
"User-defined custom distributions, created using files and function handles, are supported by the Statistics and Machine Learning Toolbox™ functions pdf, cdf, icdf, and mle, and the Statistics and Machine Learning Toolbox Distribution Fitter app."

サインインしてコメントする。

質問済み:

2018 年 2 月 22 日

コメント済み:

2018 年 2 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by