How to sample from a distribution?
95 views (last 30 days)
Show older comments
L'O.G. on 20 Jan 2023
Commented: Star Strider on 21 Jan 2023
How do you use randsample (or maybe something else?) to sample from a distribution? Can you define a non-standard distribution as long as you have the formula for the pdf?
Star Strider on 20 Jan 2023
‘How do you use randsample (or maybe something else?) to sample from a distribution?‘
The random function can be used with known distributions.
‘Can you define a non-standard distribution as long as you have the formula for the pdf?’
Yes. See Nonparametric and Empirical Probability Distributions for an extensive discussion. The ecdf function can be used to define an empirical distibution. (Getting random numbers from it would likely require inverting its pdf first, and that could be something of a challenge, depending on the distribution.)
More Answers (0)
Find more on Half-Normal Distribution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!