MATLAB Code - Mean Life Calculation

Adam Norvill
Relken Engineering
Have a question or want to speak with Adam Norvill ? Contact us with your details.


The following method is used to calculate the mean life and its time to failure distribution for a component with more than one failure mode.


  1. Identify the failure mode failure distributions for the component.
  2. Simulate 100,000 points for each failure mode distribution.
  3. Obtain the time to failure for each simulation using the minimum time of each simulated failure mode.
  4. Calculate the mean of the component failure time samples.
  5. Count failure times into histogram to identify failure shape.


Consider the example of a tyre, which has two failure modes:

  1. Failure mode 1: tyre fails due to the tread wearing out. This is expected as the tyre is used. We might expect the tyre to have a characteristic life of η = 50,000 km and a shape parameter of β = 3. This gives a MTTF of 44,644 km.
  2. Failure mode 2: tyre fails due to puncture. This is a random event that does not occur very often. We might expect on average 1 puncture (due to a nail etc.) every 200,000 km per tyre. Since it is random we can say β = 1, and MTTF = η = 200,000 km.

To simulate, we generate a random variable for each failure based on the Weibull distribution for that failure mode. In this example there are two failure modes so we generate one random variable for the tyre wearing out, and one for the tyre receiving a puncture. The random variables are a simulated time to failure for each failure mode. Of the two variables, the lowest number corresponds to the failure mode that caused the failure. This simulation occurs many times to obtain a steady state solution.

The results of the first 10 simulations are shown in the table below. For each simulation, the minimum failure time out of the two failure modes represents the time to failure, and has been highlighted red. E.g. for simulation 6, the tyre received a puncture at 55,246 km, which was before the tyre wore out. The average of the failure times (i.e. the red cells) gives the mean life for the tyre.

First Ten Failure Mode Simulations
  Failure Mode 1 (km) Failure Mode 2 (km)
Simulation 1 45171 240741
Simulation 2 52271 240741
Simulation 3 27358 576366
Simulation 4 65229 98312
Simulation 5 40956 674859
Simulation 6 86851 55246
Simulation 7 47404 170499
Simulation 8 73245 120562
Simulation 9 76037 328402
Simulation 10 42210 611274

The more simulations, the less variance there will be from a steady solution. The graphic below shows the mean life versus the number of simulations for this example. It can be seen that the mean life estimate approaches a number between 39,000 and 40,000 km. The analytical solution is 39,486 km.

While the dominant failure mode has a MTTF of 50,000 km, the effect of the less frequent failure mode brings the mean life estimate to under 40,000 km. 

 Tyre Mean Life

To see other Excel tips, traps and VBA code, see our Excel Tools resource page here.


If you have an improvement to this code, please post below.

  1. Function [ daML daBinCounts ] = mixedwblML(dAlpha, dBeta, daBinRanges)
  2. ' mixedwblML is used to determine the mean life for a component that has
  3. ' more than one failure mode. It takes the failure distribution for each
  4. ' failure mode (assumed to be a 2-parameter Weibull distribution),
  5. ' simulates the times to failure for each failure mode, and takes the
  6. ' minimum of these simulations as the simulated life. Repeating this for
  7. ' many simulations, and taking the average, will give mean life of the
  8. ' component. The inputs are the eta and beta parameters for each failure
  9. ' mode, and the 'bins' used in plotting the histogram
  11. ' Author: Adam Norvill <>
  12. ' Date: 25 Aug 2014
  13. ' Copyright: 2014 Relken Engineering
  15. ' Number of simulations
  16. sims = 1000;
  18. ' Prepare Input Variables
  19. warning('off', 'all');
  20. daA = repmat(EnsureHorizontal( dAlpha ), sims, 1);
  21. daB = repmat(EnsureHorizontal( dBeta ), sims, 1);
  22. warning('on', 'all');
  24. ' Create Random Samples for each failure mode
  25. R = wblrnd(daA,daB); ' MATLAB function that generates random Weibull distributed variables
  27. ' Obtain the life (i.e. minimum value) for each simulation, and calculate
  28. ' the average
  29. Rmin = min(R,[],2); ' Minimum value for each simulation
  30. daML = mean(Rmin); ' Average of the minimum values
  32. ' Bins the results
  33. daBinCounts = histc(Rmin, daBinRanges);