close all
clear all
%-----------------------------------
disp('Example: System with Unreliable Components')
disp('Generalized Binomial (probs different)')
lw = 3;
set(0, 'DefaultAxesFontSize', 17);
fs = 17;
msize = 20;
% Circuit: Probability that X = k out of n elements are operational
% A system S is a parallel connection of unreliable components
% e_i, i = 1, ..., 10, that work or fail independently.
% The components are operational in some fixed time interval [0, T],
% with probabilities ps =[0.5 0.3 0.2 0.5 0.6 0.4 0.2 0.4 0.7 0.8];
% Let X be the number of components that remain operational after
% time T
% Find (a) distribution of X and (b) E X and Var X.
ps =[0.5 0.3 0.2 0.5 0.6 0.4 0.2 0.4 0.7 0.8];
qs = 1- ps;
all = [ps' qs'];
[m n]= size(all);
Pnz = [1]; %initial polynomial = 1
for i = 1:m
Pnz = conv(Pnz, all(i,:) );
%polynomial multiplication as convolution
end
%at the end, Pnz is the product of p_i x + q_i
%
sum(Pnz) %the sum is 1
probs = Pnz(end:-1:1)
% 0.0010 0.0117 0.0578 0.1547 0.2507
% 0.2582 0.1716 0.0727 0.0188 0.0027
% 0.0002
%
% probabilities of exactly 0, 1, 2, ..., 10 failures.
%
% In reliability context, systems are called k-out-of-n, if they are
% operational when at least k components are operational.
% If the system, with elements/probabilities as before is 4-out-of-10,
% whet is the probability that it ios operational?
% Need to find sum_{i=4,10}(Pnz(i)) = 1- sum_{i=0,3}(Pnz(i)).
1-sum(probs(1:4))
% 0.7749
% mean and variance of the generalized binomial
k = 0:10;
EX = k * probs' %expectation 4.6
EX2 = k.^2 * probs' %second moment 23.28
VX = EX2 - (EX)^2 %variance 2.12