Friday, May 23, 2014

I Have No Horn and I Must Honk

LabKitty DnD Logo
Some say the most vile invention ever invented by inventors was weaponized smallpox. Others say C++ or the boy band.

Those people are wrong.

If there was ever someone deserving of having a time-traveling killer robot sicced upon his unsuspecting waitress of a mother (and, yes, perhaps even an Academy Award winning sequel, but not so much a third outing which undoes much of the mythology established in the first two films, even if the crane chase was a welcome return to practical SFX) it would be the inventor of the car alarm.

But LabKitty, I hear you protest, if my car does not have an alarm, the valets at Spagos will look at me funny. I may as well be driving a bicycle, and not one of those cool bicycles with the $1500 Shimano derailleurs, but one of those old-timey bicycles with the oversized front wheel and Tyrannosaurs-arm handlebars.

You say that because you do not understand what a car alarm is. Wires and electronics and motion sensors and a horn? No, that is incorrect. To borrow from Jack Sparrow, that's what a car alarm needs.

What a car alarm is, is Type-I error.



Apparently, the bad news is there's so many types of error that we have to number them. Like world wars. The good news is there's only two. Also like world wars (fingers crossed).

Only two kinds of error?  I hear you protest. How can that be??

An eminently understandable reaction. After all, I made a dozen errors just typing this sentence. Not to mention being married and getting married and what I had for breakfast. And don't get me started on the innumerable errors that are peeling off my DNA at this very moment, sure to transcribe into improper phosphorylation that will in time ignite a cancerous horde should today the rebel cells escape notice of my stalwart immune system (go get 'em, immune system! Eat those bastard cells! Eat 'em up!)

But, yes, we can condense the infinite cornucopia of errors in this world by shooting them through the appropriate simplifying lens, like Machiavelli simplified a world of infinite political intrigue into black and white realpolitik using the lens of jaundiced cynicism.

Our simplifying lens is called signal detection theory (or just "decision theory" if you're not into radar or psychophysics).

Applying the lens requires recasting the issue at hand as a yes/no question. For example: Two households, both alike in dignity becomes Is the dignity of House Capulet alike to that of House Harkonnen? Or: In a hole in the ground there lived a Hobbit becomes Does a Hobbit live in this hole?  When Zack De La Roacha bemoans never seeing the color of his father's eyes, he should instead ask: Are my father's eyes brown? (I'm guessing they are). Sometime the question is more naturally framed as true/false or 0/1 or present/absent rather than yes/no. But the gist is the same.

Now comes the boom. Given any yes/no question, you can answer yes or you can answer no. And you can be right or you can be wrong. We have thusly reduced your interaction with the entire sphere of existence to four possibilities:

You can say yes and be right.
You can say yes and be wrong.
You can say no and be right.
You can say no and be wrong.

One need not crack open the modus ponens to see that within these four possibilities two are in error. Consider the boy who cried wolf: If he cries wolf and there is no wolf, he has made a Type-I error -- a false alarm. Thus begins the fable. If he does not cry wolf when the wolf is indeed come, he has made a Type-II error -- a missed detection. Not how the fable ends, but it would have if the Brother's Grimm aimed to provide a proper lesson in the statistical majicks.

a 2x2 decision matrix showing type-I and type-II error

This simple schema provides an approach to most things in life. A way to organize that herd of cats scampering around inside your noggin. We might even call it a philosophy, no less then Feng-shui or Zoroastrianism (oddly enough, Ahura Mazda is a Zoroastrian god, a Mazda is a type of car, and cars have alarms. Coincidence? You must decide.)

But we may go further. Unlike most systems of philosophy, we can attach numbers to ours.(Suck it, Socrates.)

Let us use the notation P(wawa) to indicate the probability of  "wawa" happening. Classic example: P(heads) indicates the probability of getting heads on a coin toss, usually abbreviated P(H). Steering things back toward the topic at hand, I will use P(A) to indicate the probability of a car alarm going off. P(T) is the probability a thief is present. Signal detection theory is interested in combinations of events -- you may know them as "conditional probabilities" -- which are indicated using a vertical bar. The two quantities we require are P(A|T) or the probability of alarm given that a thief is present, and P(T|A) or the probability that a thief is present given that the alarm is going off. Note these are different quantities: they describe different situations and take on different probability values. If necessary, pause here and reflect upon this before proceeding.

Finally, we will use a squiggly to indicate negation. So, for a coin toss, P(~H) is the probably of not tossing a heads (what normal people call "tossing a tails"). For the car alarm problem, one expression drives us: P(A|~T) -- the probability of an alarm given no thief is present. This should be setting your Spidey sense on edge as precisely Type-I error.

And now, imagine: the alarm has been sounded. What to do? Shall we investigate? Call the cops? Form a posse? Great Caesar's Ghost! There is a car alarm! WHY ARE YOU PEOPLE NOT MOUNTING THE PARAPETS?? Are you deefe?

In more sober terms, we seek to establish the probability that hearing a car alarm does in fact indicate that a car theft is in progress. Using conditional probability notation, we seek P(T|A) -- the probability of theft given alarm. This is a number between 0 and 1. A number close to one tells us we should pay attention. A number close to zero allows us to roll over and try to get back to sleep, as we have to be up for work in another two goddam hours.

I suspect you see where this is headed, but we have to crunch the numbers for the privilege of saying "told ya." To get P(T|A) we use Bayes' Theorem. Because my typing fingers and your patience are likely both weary, I'm just going to write it down. Someday I may revisit Bayes' Theorem and the Great Rift it rifted in Scienceland, but that is a story for another time. For now:

  P(T|A) = P(A|T)P(T)/[P(A|T)P(T) + P(A|~T)P(~T)]

Now to stick in some numbers.

The FBI (www.fbi.gov) reports there were 715,373 car thefts in 2011 (the most recent year they provide data for.). We need to massage this number to use it in our analysis.

First, the FBI number is for the entire country. Our subtext is a car alarm within earshot, so we need theft rate within earshot. Assuming a car alarm is audible over, say, a square mile, we would divide 715,373 by 3,790,000, the land area of the United States (source: Wikipedia). However, that's overly conservative as the land area is mostly purple mountains something and amber waves of grain, neither of which contain many cars. So, let's bump up the figure x100; in effect we're assuming any car alarm is audible over 100 square miles. (715,373 / 3,790,000) x 100 gives 18.88.

Second, the FBI number is for the entire year. Let's look at, say, one hour. One blessed, gospel, hallelujah hour when we might not be subjected to the pointless caterwauling of one of these useless f-ing things (sorry; I'm a little punchy right now). So we divide 18.88 by (365 x 24) to get an hourly theft rate within earshot of 0.0022.

Finally, to convert hourly rate into an hourly probability we assume the theft rate is constant which gives theft probability as Poisson-distributed (see any probability textbook). The probability of one or more thefts in an hour is one minus the probability of no thefts in an hour, or 1 − exp(-0.0022) = 0.0022.

Thus, P(T), the probability of at least one theft within earshot in any given hour, is equal to 0.0022. Also, P(~T) = 1 – P(T) = 0.9978.

Footnote: It's not a coincidence that the rate and the probability are equal (to within four decimal places). This happens when rates are tiny.

Footnote: Yes, there's much about this calculation that can be criticized. Car thefts are not uniform in space or time (California is a cesspool of thievery compared to the sanguine streets of Circle Pines and it's likely more or fewer thefts occur on holidays) and not all of the cars stolen had alarms. We could even take a step back and use a more sophisticated signal detection tool like minimax or Neyman-Pearson. To cover my bases, I hereby offer these extensions as an exercise for the reader.

We now have P(T) and P(~T). This leaves P(A|T) and P(A|~T) in the formula which, alas, we don't know. How to proceed?

First, I'm going to assume a thief sets off your alarm 99 times out of 100, i.e., a missed detection rate of 1%. Yes, it may be that the shadowy underworld of international car thievery has an insatiable lust for your '97 Torus and are at this very moment devising techniques for circumventing the Viper Hoopy Sentential system you purchased -- techniques no doubt involving Catherine Zeta Jones wearing yoga pants. But closer to reality is if your car is being broken into at all it is by some street urchin executing a smash-n-grab because you left your purse/backpack/briefcase in the backseat. Again. In short: we're dealing with physics not espionage, and with concomitant alarm. Hence, I assume P(A|T) = 0.99.

Next: what shall we use for P(A|~T), the probability of alarm given no thief aka a false alarm aka Type-I error?

In important applications, where a false alarm comes with an associated clear and present danger (like launching a superfluous nuclear counterstrike), the designers of an alarm system have a vested interest in minimizing Type-I error. However, the DeVry dropouts building car alarms don't much suffer when their product makes a Type-I error. Sure, the end-user might, say, through face-punching. But the fetid monks hunched over their soldering stations down at Viper Hoopy Inc. don't give a rat sass if their product bleats out clarion alarm all the livelong day, thief or no. Either way they're drawing a paycheck and putting food on the table for their little fetid monk children.

That being said, I'm not going to assume anything for P(A|~T) for the simple reason I don't have to. P(A|~T) is a probability, so it's a number between 0 and 1. Let's plot P(T|A) -- the probability of interest we get from Bayes' formula -- for all possible values of P(A|~T) using the values of P(T) and P(A|T) computed above and see what happens.

Take it away MATLAB:

a plot of probability of heft given alarm vs type-I error

From this we see that unless the false alarm probability is small (and by "small" I mean nuclear launch small) the chance of a car alarm indicating a car theft is actually in-progress is negligible. To put it another way: for all intensive porpoises, the alarm rate and the false alarm rate are identical. And to put it yet another way: if your car alarm is going off, probably under my bedroom window at 4 AM, there is about a 0% chance that someone is actually trying to steal your goddam car. Whence the alarm? Who knows. The wind. System error. The neighbor's cat padding down the other side of the street. Christine attempting to make Her presence manifest. Your idiot boyfriend who can't remember this happens every time he sets the alarm with the keychain dongle then opens the trunk to retrieve his 12 pack of Natty Lite. Does it really matter?

Ergo the take-home: a car alarm is not wires and electronics and motion sensors and a horn. What a car alarm is, what a car alarm really is, is Type-I error. QED.

Epilogue

clip art car with alram on fire

In closing, if any members of Congress happen to be reading this, perhaps because the NSA-bot 3000 brought it to your attention, I humbly offer the following policy recommendations be taken under consideration, that we might secure the blessing of liberty for ourselves and our posterity yadda yadda:

1) If you can't operate your car without setting off your own car alarm, YOU DON'T GET TO HAVE A CAR ALARM.

2) If your car alarm goes off under my bedroom window and I set your car on fire, you have to pay me $40.

LabKitty: the voice of reason in a world gone mad (tm).

Car Alarm Bumper Sticker
Car Alarm Bumper Sticker by LabKitty
Find other Labkitty Bumper Stickers at zazzle.com

No comments:

Post a Comment