MATLAB Answers

0

How to generate a random sequence with some specific probability

Asked by Huiwen Wu on 22 Feb 2018
Latest activity Commented on by Walter Roberson
on 23 Feb 2018
How to generate a random sequence with some specific probability except the randn for normal and rand for uniform distribution?

  0 Comments

Sign in to comment.

2 Answers

Answer by Image Analyst
on 22 Feb 2018

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.

  0 Comments

Sign in to comment.


Answer by Walter Roberson
on 22 Feb 2018

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

  2 Comments

Thank you! Can I define a probability distribution by myself? Not the one in the list.
"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."

Sign in to comment.