{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"# Simple exercises in reliability engineering"
]
},
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"\n",
"\n",
"This notebook is an element of the free [risk-engineering.org courseware](https://risk-engineering.org/). It can be distributed under the terms of the [Creative Commons Attribution-ShareAlike licence](https://creativecommons.org/licenses/by-sa/4.0/). \n",
"\n",
"Author: Eric Marsden . \n",
"\n",
"---\n",
"\n",
"This notebook contains a number of simple exercises in reliability engineering. For background, see the [associated lecture notes at risk-engineering.org](https://risk-engineering.org/reliability-engineering/). "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"autoscroll": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"import numpy\n",
"import scipy.stats"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Lifetime of light bulbs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The lifetime of a modern low-wattage electronic light bulb is known to be exponentially\n",
"distributed with a mean of 8000 hours.\n",
"\n",
"- **Q1**. Find the proportion of bulbs that may be expected to fail before 7000 hours of use.\n",
"\n",
"- **Q2** What is the lifetime that we have 95% confidence will be exceeded?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Answer**. The time to failure of our light bulbs can be modelled by the distribution"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"dist = scipy.stats.expon(scale=8000)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Q1**: The CDF gives us the probability that the lifetime is ≤ $t$."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.5831379803214916"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dist.cdf(7000)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So about 58% of light bulbs will fail before they reach 7000 hours of operation."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Q2**: We need the 0.05 quantile of the lifetime distribution, which is given by the `ppf` function in scipy.stats. "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"410.3463551004043"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# the result is expressed in hours\n",
"dist.ppf(0.05)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Failure of electronic components"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A particular electronic device will only function correctly if two essential components both function correctly. The lifetime of the first component is known to be exponentially\n",
"distributed with a mean of 5000 hours and the lifetime of the second component (whose failures can be assumed to be independent of those of the first component) is known to be exponentially\n",
"distributed with a mean of 7000 hours. \n",
"\n",
"**Q**. Find the proportion of devices that may be expected to fail before 6000 hours use."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**A**. The device will only be working after 6000 hours if both components are operating. \n",
"The probability of the first component still working after 6000 hours is "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.3011942119122022"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pa = 1 - scipy.stats.expon(scale=5000).cdf(6000)\n",
"pa"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"and likewise for the second component"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.42437284567695"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pb = 1 - scipy.stats.expon(scale=7000).cdf(6000)\n",
"pb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability of both working is"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.12781864481060756"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pa * pb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"so the proportion of devices that can be expected to fail before 6000 hours' use is around 87%. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Maintenance of a large computing facility"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For a large computer installation, the maintenance logbook shows that over a period of a\n",
"month there were 15 unscheduled maintenance actions or downtimes, and a total of 1200 minutes in emergency maintenance status. Based upon prior data on this equipment, the reliability engineer expects repair times to be exponentially distributed. A warranty contract between\n",
"the computer company and the customer calls for a penalty payment for any downtime exceeding\n",
"100 minutes. Find the following:\n",
"\n",
"- The MTTR and repair rate\n",
"\n",
"- The probability that the warranty requirement is being met\n",
"\n",
"- The median time to repair\n",
"\n",
"- The time within which 95% of the maintenance actions can be completed"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**A**. The MTTR (mean time to repair) is simply the mean of the observed repair times. We saw 15 repairs for a total of 1200 minutes of repair time, meaning that MTTR = 1200/15 = 80 minutes. The repair rate μ is the inverse of the MTTR, 1/80 = 0.0125. Our probability\n",
"distribution for repair times is"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"dist = scipy.stats.expon(scale=80)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability of time to repair not exceeding 100 minutes is given by the cumulative distribution function of the repair time:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.7134952031398099"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
" dist.cdf(100)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The median time to repair is the 0.5 quantile"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"55.451774444795625"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# this is in minutes\n",
"dist.ppf(0.5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The time within which 95% of the maintenance actions can be completed is"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"239.6585818843192"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# this is in minutes\n",
"dist.ppf(0.95)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Failure of pumps in an oil field"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From field data in an oil field, the time to failure of a pump, $X$, is known to be normally distributed. The mean and standard deviation of the time to failure are estimated from historical data as 3200 and 600 hours, respectively. \n",
"\n",
"- What is the probability that a pump will fail after it has worked for 2000 hours?\n",
"\n",
"- If two pumps work in parallel, what is probability that the system will fail after it has worked for 2000 hours?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We want to assess $\\Pr(X < 2000)$, which is $1 - \\Pr(X ≥ 2000)$, or"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9772498680518208"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 - scipy.stats.norm(3200, 600).cdf(2000)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability of the system working for at least 2000 hours is 1 - that of both pumps failing before 2000 hours, which is 1 - 0.977², or 0.9994.\n",
"\n",
"Let’s call $Y$ the random variable representing time to failure of the redundant pump system, and $X_1$ and $X_2$ the time to failure of pumps 1 and 2 respectively. We want to\n",
"determine $\\Pr(Y > 2000)$, which is $1 - \\Pr(Y ≤ 2000)$.\n",
" \n",
"This is $1 - \\Pr(X_1 ≤ 2000 ∧ X_2 ≤ 2000)$ (given the parallel configuration of the pumps,\n",
"the system fails when both of the pumps fail).\n",
"\n",
"Given that pump failure is independent, that’s $1 - \\Pr(X_1 ≤ 2000) × \\Pr(X_2 ≤ 2000)$. So it's"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9994824314963404"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 - scipy.stats.norm(3200, 600).cdf(2000)**2"
]
}
],
"metadata": {
"anaconda-cloud": null,
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
},
"name": "basic-statistics.ipynb"
},
"nbformat": 4,
"nbformat_minor": 1
}