MATLAB: Generate random values from a pdf within a given interval

distributionpdfrandom

Hi,
I wish to generate random values from a given probability density distribution that's only within a certain interval. Is there a smart way to do this?
Chris

Best Answer

Whether there is a smart way or not depends a lot on the pdf. If you are using uniform random then, Yes, there is. If you are using beta distribution, adjust the parameters to only cover that range. For anything else, typically there is no "smart" way of doing it, partly because any other kind of distribution has at least one infinite tail and truncating an infinite distribution gives you something that does not belong to any probability distribution.
There is a convenience function if you are using Statistics Toolbox: http://www.mathworks.com/help/stats/prob.truncatabledistribution.truncate.html
Related Question