Skip to content

Commit 938ec07

Browse files
committed
More tweaking.
1 parent 2a0ddda commit 938ec07

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

Diff for: calculation.ipynb

+14-9
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"to the topic.\n",
1818
"\n",
1919
"The *failure rate* for a widget over a period of time is the average number \n",
20-
"of failures in that time per widget. An annual failure \n",
21-
"rate of 0.25 means that on average, there are 0.25 failures per widgets.\n",
20+
"of failures in that period per widget. An annual failure \n",
21+
"rate of 0.25 means that on average, there are 0.25 failures per widget.\n",
2222
"If you have 100 widgets for one year, there would be an average of 25 failures per year.\n",
2323
"\n",
2424
"A failure rate of 0.25 is frequently written as 25%.\n",
@@ -57,11 +57,14 @@
5757
"\n",
5858
"If you add up the infinite sequence of probabilites, it will add up to 1.0.\n",
5959
"\n",
60+
"To calculate the probability of zero failures, you can simplify the formula:\n",
61+
"\n",
62+
"$$\\text{probability of 0 failures} = e^{-\\lambda} \\: \\frac{\\lambda^0}{0!} \\: = \\: \\: e^{-\\lambda}$$\n",
63+
"\n",
6064
"The probability of having at least one failure is the sum of entries from 1 on, which is \n",
61-
"the same as one minus the probability of 0 failures. Because $lambda^0 = 1$ and $0! = 1$,\n",
62-
"the formula can be simplified:\n",
65+
"the same as one minus the probability of 0 failures:\n",
6366
"\n",
64-
"$$\\text{probability of 0 failures} = 1 \\: - \\: e^{-\\lambda} \\: \\frac{\\lambda^0}{0!} \\: = \\: 1 \\: - \\: e^{-\\lambda}$$\n",
67+
"$$\\text{probability of one or more failures} \\: = \\: 1 \\: - \\: e^{-\\lambda}$$\n",
6568
"\n",
6669
"We'll use this formula later to calculate the probability of failures given a failure rate.\n",
6770
"\n",
@@ -72,7 +75,7 @@
7275
"Let's look at an example: You have three widgets with an annual failure rate of 0.25 (25%). \n",
7376
"What is the probability that 2 or more of the three widgets will fail in the year?\n",
7477
"\n",
75-
"We'll use $P$ for the probability of a given widget failing at least one time.\n",
78+
"We'll use $P$ for the probability of a given widget failing at least once in the period.\n",
7679
"Using the formula from the prevous section, that probability is $0.2212$:\n",
7780
"\n",
7881
"$$P = 1 - e^{-0.25} \\approx 0.2212$$\n",
@@ -81,9 +84,11 @@
8184
"\n",
8285
"$$\\text{probability of not failing} = 1 - P \\approx 0.7788$$\n",
8386
"\n",
84-
"There are eight possible combinations of failure for the three widgets. The first one is that none of them fail. The probability for that is the product of the probabilities for each of the widgets: $0.7788 * 0.7788 * 0.7788 = 0.4724$$\n",
87+
"There are eight possible combinations of failure for the three widgets. The first one is that none of them fail. The probability for that is the product of the probabilities for each of the widgets not failing: $0.7788 \\times 0.7788 \\times 0.7788 = 0.4724$\n",
8588
"\n",
86-
"We can compute the probability of all eight cases:\n",
89+
"We can compute the probability of all eight cases by taking the probability that each\n",
90+
"widget will be OK or FAIL and multiplying them together. The sum of the resulting probabilities\n",
91+
"in the right column add up to 1.0:\n",
8792
"\n",
8893
"A | A prob | B | B prob | C | C prob | Probability\n",
8994
"--- | --- | --- | --- | --- | --- | ---\n",
@@ -99,7 +104,7 @@
99104
"To get the probability of two or more failing, we add up the probabilities of all\n",
100105
"rows that have two or more failures. The rows with exactly two failures add up\n",
101106
"to $0.1143$. The one row with three failures has a probability of $0.0108$. Those\n",
102-
"add up to a $0.1251$ probability of two or more failures.\n",
107+
"add up to a probability of $0.1251$ for two or more failures.\n",
103108
"\n",
104109
"You'll notice that all of the rows with two failures have the same probability,\n",
105110
"which makes sense. The number of those rows is given by: $\\binom{3}{2}$, which \n",

Diff for: durability.py

+2
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ def example():
352352
})
353353
total_prob += probs[a] * probs[b] * probs[c]
354354
print_markdown_table(data, ['A', 'A prob', 'B', 'B prob', 'C', 'C prob', 'Probability'])
355+
print 'sum of probabilities: %6.4f' % total_prob
356+
print
355357

356358
data = [
357359
{'Number of Failures': str(k), 'Probability': '%6.4f' % binomial_probability(k, 3, p_one_failing)}

0 commit comments

Comments
 (0)