% A Complex Circuit
clear all
rand('twister',1)
st = 0;
M=1000000;
for i = 1:M
e = rand(1,13) < 0.8;
s1 = e(5) + e(6) + e(7) > 0;
s2 = e(3) + e(4) > 0;
s3 = e(2) * s1 * s2;
s4 = e(8) * e(9);
s5 = e(12) * e(13);
s6 = e(11) + s5 > 0;
s7 = e(10) * s6;
s = e(1) + s3 + s4 + s7 > 0;
st = st + s;
end
st/M  %0.9955 (exact result is 0.9953)
