# Calculating the cost of failure

We set up our business to sell high quality cables at a reasonable price. In order to do this, we order cables from a reputable supplier and then run them through testing to ensure their quality remains high.

Let's be realistic though - if it's a physical item, it can break. It's time consuming and expensive to return batches that have a high amount of failing cables to the supplier, so we need to find the cost to us of a bad batch. This lets us then know how many cables need to bad in the batch before it's worth returning it.

So, how did we plan for the cost of cables failing?

Initially, unless you have a way of testing your product, you'll have to guess this. The more durable it is the better! Don't fall into the trap of assuming that your product is unbreakable. Take the percentage that will fail and add that to the cost per cable. Let's say the cost to us of a cable is around \$5. If 2% of them fail, then we'd add 2% to the cost of the cable, so the new cost to us would be \$5.10.

Or so we thought.

As a thought experiment, Tommy played around with increasing the failure percentage. Increasing it to 20% failure by our logic would mean that our cost for a \$5 cable would be \$6. At 50% we'd be have a \$5 for \$7.50. That doesn't make any sense. If we ordered 100 cables and 50 of them were bad, we'd have to return one in every two cables, so it should cost us about \$10!

After some thought we came to the conclusion that what we hadn't thought of was the cost of replacing the replacement.

Let’s change what we are selling for this discussion, because if I get a batch of cables where 50% of them are bad, I'm not going to be happy, and we aren't dealing with that supplier again. For now, I’m going to write about Joe’s Glass Importing store. We import fancy glass holiday drinking glasses and do big pushes around Christmas/Easter, meaning we don’t have time to return the batch and get a new one. We need to find what cost to sell the batch at to make a profit. I’m going to go and QA a batch of 100 glasses. I find 50 of them are bad. This means that if I select a random glass, there’s a 50% chance it has stress fractures causing it to break too easily. If I take out a bad one and set it to one side, I then draw a new glass out of the box to send to my customer. There’s nothing that says that this one is going to be good In fact, logically, the odds of this one being bad are very nearly 50% too (there's 49 bad and 50 good in the box still). This logic carries onto the next one, and the one after. You have to select quite a few glasses before the odds change dramatically.

What this means is that when we are using our percentages (or probabilities), we need to account for cases where we keep selecting bad glasses. Quick probability refresher- if I want to calculate the odds of rolling double six, I take the probability of rolling a 6 (1 result in 6) and multiply it by the probability of rolling another 6 (1 in 6). 1/6 times 1/6 is 1/36.  If I want to calculate the odds of rolling either a 5 or a 6 on one dice, I add the two probabilities together. The odds of rolling a 5 is 1 in 6, the odds of rolling a 6 is 1 in 6. So the odds of rolling a 5 or a 6 is (1/6 plus 1/6) 2/6, or, 1/3.

Let me represent the probability of the glass having stress fractures by “x". The chance of the first glass and the second glass both having them is the x multiplied by x (x2). The chance of the first, second and third glass is x multiplied by x multiplied by x (x3). We want the chance of the first glass having fractures (x) or the chance of the second and first failing (x2) or the chance of the 3rd glass failing (x3) up to the size of the batch. Which is x + x2 + x3 + x4 etc etc.

This equation is called a Taylor Series, and it works out as 1/(1-x) - 1. Remember, x is our probability of a single glass failing, so let's plug some numbers in.

For a failure rate of 2%, x is 0.02. That means we do 1 divided by 0.98, minus 1, which is 0.0204. In other words, the chance of pulling multiple failing glasses is basically non-existent at 2%. Good. However, let's go back up to our 50% batch. At 50%, 1/0.5 - 1 works out to 1, meaning we'd have to double the cost of our glass to make profit off the batch. Makes sense. Let's get a ludicrous batch where 90% of them fail! For this, we'd have to charge 9 times the cost of the glass in order to break even.

Hopefully you find this useful. Mathematics is somewhat of a side passion of mine and I love to get a chance to use it.