How do you program CLT?
4 次查看(过去 30 天)
显示 更早的评论
Plot the histogram of 10000 random variables, where each random variable is the mean of n continuous uniform random variables.
Vary n from 1 to 10. The histogram should look increasingly Gaussian as n increases.
Demonstrate the CLT sum the following random variables that you should know how to generate (a) exponential λ = 1 (b) Bernoulli p = 0.5 (c) binomial (5, 0.5) (d) normal N(0, 1)
0 个评论
采纳的回答
Roger Stafford
2014-4-5
Bill, this seems like a rather straightforward assignment, demonstrating the famous central limit theorem. In what respect are you having difficulty with it? As I see it, you should create a 10000-by-n array for each of the values of n from 1 to 10, consisting of random numbers generated by the various required distribution types. That is surely straightforward. Then take the means of each row which will yield ten 10000-by-1 arrays - again very straightforward one-liners. Finally you need to produce histograms of each of these ten arrays, which will necessitate studying up on matlab's histogram functions.
I find the requirement of distribution (d), the normal distribution, rather curious. It is already entirely Gaussian, so what do they expect you to demonstrate there? How Gaussian can you get? All that will happen is a reduction in its standard deviation by one over the square root of n.
0 个评论
更多回答(2 个)
Image Analyst
2014-4-5
Hint:
n = 5 % for example.
rv = mean(rand(10000, n), 2) % Mean of n random numbers.
bar(rv) % just for display - to see them.
0 个评论
Joseph Cheng
2014-4-4
you can look at conv() which will do a rolling sum. With the rolling sum you just need to divide by the number of elements to get the rolling average.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!