% simple MATLAB/Octave program to simulate Mean Time Between Failures Ns = 10000; % number of simulations Np = 3; % number of parts in product mu = [11 12 13]; % mean life span of every part sigma = [1 2 3]; % standard deviation for each part sample = [0 0 0]; % allocate memory for samples m = 0; s = 0; % mean and standard deviation for product for i=1:Ns % randn samples for normal distribution for j=1:Np % with mean 0 and standard deviation 1 sample(j) = mu(j) + sigma(j)*randn; end; t = min(sample); % product fails if one of its components fails m = m + t/Ns; % update mean life span for the product s = s + t^2/Ns; % update the second moment end; m % report the mean life span of product s = sqrt(s - m*m) % standard deviation of life span