i need some help to do this assignment

7 views (last 30 days)
abdalmoed
abdalmoed on 16 Dec 2016
Answered: Image Analyst on 16 Dec 2016
Using Matlab find and draw the PDF for sum of random variables And find the value of n that makes PDF of X is almost normal assuming the random variables xi are independent when:
  1. xi each is uniformly distributed between 1 and 4
  2. xi each has an exponential distribution
  3. xi each has Gamma distribution
  2 Comments
the cyclist
the cyclist on 16 Dec 2016
Please show your work so far, and ask specific questions. Otherwise, we are just doing your homework for you, which doesn't help anyone.
If you have no idea how to even get started, I suggest you go to your teacher and tell them that you need some help.
Steven Lord
Steven Lord on 16 Dec 2016
If you post what you've done to try to solve this problem and ask a specific question you may receive some suggestions about how to move forward.

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 16 Dec 2016
Hint
numPoints = 1000000; % A million
r = a + b * rand(6, numPoints);
r2 = sum(.................
histogram(......... 'normalization', 'pdf');
Fill in the missing parts, like specifying a and b, and figuring out which direction to sum along.

John BG
John BG on 16 Dec 2016
Edited: John BG on 16 Dec 2016
Hi Abdalmoed
the individual variables can be generated with command random and choosing the right parameters.
1.- the Uniform random variable:
random('unif',-1,1,[2,10])
ans =
Columns 1 through 4
0.140388364616905 0.115006106218135 -0.681854354948525 0.368405566549703
-0.307058891183061 -0.400430594996851 0.330512571745190 0.584818724696582
Columns 5 through 8
-0.302751124680212 -0.309993229412276 0.854971065784233 -0.423522733150631
-0.499850533293865 -0.342734814268997 0.512144864907407 0.212359752297196
Columns 9 through 10
0.532058728474376 0.803962383757906
0.692304688549677 0.191414295157756
while the option 'unid' stands for 'Uniform Discrete' and generates integer values only
random('unid',11,[2,10])
ans =
10 2 10 11 11 5 2 9 11 5
11 6 8 11 1 4 2 6 11 5
as example, given 4 uniform within interval [1 11] their sum is:
x_uni=random('unid',11,[4,16]);sum(x_uni)
=
Columns 1 through 14
13 25 22 19 26 29 19 22 27 15 23 27 27 16
Columns 15 through 16
20 14
2.- Exponential random variables
mu=3.4;x_exp=random('exp',mu,[4,16])
x_exp =
Columns 1 through 4
0.747390811800658 0.994697359542255 1.584931681939522 1.143912461423403
3.043231553115649 5.946460056747544 0.585159077605395 0.331743811268225
3.796431225409398 7.279181468268765 2.288819160283776 5.170708273906848
0.996233780987489 5.944846775150977 6.110451895056359 0.469735720942112
Columns 5 through 8
5.276606726169461 2.514226907499281 1.620948697702713 6.709428349496696
0.606327436394538 0.396661463895200 1.053441526608499 0.890815803727979
0.515559710281193 9.289467697429171 4.996954016021975 0.104384482319141
2.201337920647128 2.292999248088371 12.996682519215380 3.229530636240572
Columns 9 through 12
0.022419267724480 1.955417159671335 6.245114291216864 2.604431914745639
3.806815675707256 1.550284187340987 6.391417871297358 7.405099641655804
6.754438629192524 2.084933612850595 6.759654696912856 1.208428775677642
3.247517043337815 3.927691951607198 1.165410004232284 5.830576513166785
Columns 13 through 16
0.743134363121325 0.824824445073596 1.111457855251677 2.723996909548314
2.263099215734687 2.181180371040178 8.892370053410488 1.451206838563764
2.042313297284674 1.905105521050411 1.766048299719335 4.054371628774340
5.341277010898176 2.933021508726013 0.504989311100312 1.694906646392078
and
sum(x_exp)
=
Columns 1 through 4
8.583287371313196 20.165185659709540 10.569361814885053 7.116100267540588
Columns 5 through 8
8.599831793492319 14.493355316912021 20.668026759548567 10.934159271784388
Columns 9 through 12
13.831190615962075 9.518326911470115 20.561596863659361 17.048536845245870
Columns 13 through 16
10.389823887038862 7.844131845890198 12.274865519481812 9.924482023278499
3.- Gamma distribution
a_shape=2;b_scale=4;x_gam=random('gam',a_shape,b_scale,[4,16])
sum(x_gam)
=
Columns 1 through 4
54.751998014941194 47.301768719164038 43.496577602765420 21.025506683079620
Columns 5 through 8
43.361110310741516 17.822143281264754 14.282474773780082 48.930570878037656
Columns 9 through 12
49.988994494054509 29.338093788676147 23.207683541421702 23.365178434648705
Columns 13 through 16
13.499273922587927 31.569413017472254 22.033540392929719 31.083431834385511
4.- You can check that for long chains, the histogram of each random variable should resemble the respective probability distribution function
x2_uni=random('unid',160,[1,1600]);
figure(1);histx2uni=histogram(x2_uni);histx2uni.BinWidth=1;title('uniform')
mu=40;x2_exp=random('exp',mu,[1,1600]);
figure(2);histx2exp=histogram(x2_exp);histx2exp.BinWidth=1;title('exponential')
a_shape=3;b_scale=4;x2_gam=random('gam',a_shape,b_scale,[1,1600]);
figure(3);histx2gam=histogram(x2_gam);histx2gam.BinWidth=1;title('gamma')
.
5.- If you are considering plotting the different pdfs or even the random variables themselves on same graph it would be a good idea to normalise traces with their respective mean values:
N=10;
x3_uni=random('unid',160,[N,1600]);
figure(5);histsumNuni=histogram(sum(x3_uni)/N);histsumNuni.BinWidth=1;title('sum N rand uniforms')
mu=40;x3_exp=random('exp',mu,[N,1600]);
hold all;figure(5);histsumNexp=histogram(sum(x3_exp)/N);histsumNexp.BinWidth=1;title('sum N rand exponentials')
a_shape=3;b_scale=4;x3_gam=random('gam',a_shape,b_scale,[N,1600]);
hold all; figure(5);histsumNgam=histogram(sum(x2_gam)/N);histsumNgam.BinWidth=1;title('sum N rand gammas')
.
On this graph we can see that all sums of histograms tend to look like Gaussian probability distribution 'bells', which is probably what you are after, to understand the Central Limit Theorem, recommended reading
.
So Abdalmoed
forum users Cyclist and Lord have many many credit points, so they can afford the luxury of trying to tell you to do your homework instead of answering your question. .
I don't have so many points, so believe I have answered your answer without hesitation or asking you anything in return.
.
Would you please be so kind to mark my answer as Accepted Answer .
To any other reader, please if you find this answer of any help please click on the thumbs-up vote link,
thanks in advance
John BG

Community Treasure Hunt

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

Start Hunting!