Generating data points according to a distribution
显示 更早的评论
I've an array that is the distribution of a RV. Is there any way I can generate points which satisfies this distribution? Please note that it is not any standard distribution function.
Thanks
回答(1 个)
Tom Lane
2012-6-7
0 个投票
1. If RV is a set of possible data points, you can randomly sample from it. One way to do that if you have the Statistics Toolbox is to use the datasample function.
2. If RV is a large random sample from the distribution but not the whole distribution, you could think of estimating the distribution using ksdensity and generating from that. An equivalent thing would be to randomly sample from RV and add some noise, perhaps using u*randn where u is your desired bandwidth and randn is the function that generates standard normal values.
3. Sounds like this is not true, but if RV were an inverse cdf function, you could generate random probability values using rand and invert them.
4. Sounds like this is not true, but if RV were a density function things are a little harder, but the slicesample function can generate correlated values from it, and the set of these values might be adequate for your purposes.
2 个评论
Prabhu
2012-6-7
Tom Lane
2012-6-7
The Statistics Toolbox has a function norminv for computing the inverse cdf of the normal distribution. You could run norminv(rand) to get a normal random value. It turns out that we also have normrnd for generating normal random numbers directly by a method we think is better. But if you only had norminv or some other inverse cdf, you could generate random numbers this way.
类别
在 帮助中心 和 File Exchange 中查找有关 Uniform Distribution (Continuous) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!