blob: 6668d90df46d5d733b3505c00ecc0f281cd17394 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
//Chapter 07: Discrete Probability
clc;
clear;
X=[1,2,3,4,5,6] //possible values on a fair die
p=1/6 //probability for any value to appear when die is rolled
Ex=0
l=length(X)
for i=1:l
Ex=Ex+p*X(i)
end
disp(Ex,'Expected value of X')
|