How do you program CLT?

22 ビュー (過去 30 日間)
Bill King
Bill King 2014 年 4 月 4 日
回答済み: Image Analyst 2014 年 4 月 5 日
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)

採用された回答

Roger Stafford
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.

その他の回答 (2 件)

Image Analyst
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.

Joseph Cheng
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by