Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SN = [];
- n = 1000000;
- m = 1000;
- for i = 1:n
- aR = [];
- for j = 1:m
- x = rand;
- if x < 0.5
- aR(j) = 1;
- elseif x < 0.7
- aR(j) = 2;
- elseif x < 0.9
- aR(j) = 3;
- else
- aR(j) = 4;
- end
- end
- SN(i) = sum(aR)/sqrt(m);
- end
- A = (var(SN));
- figure(1)
- histogram(SN, 'Normalization', 'pdf')
- figure(2)
- histogram(SN, 'Normalization', 'cdf')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement