# Belay That Photon Torpedo Order!!!

This post is about the application of Conditional Probability and Bayes Theorem in target detection by a randomly maneouvering search platform. Most tutorials about Bayes Theorem on the internet deal with issues like cancer detection maths or picking coloured balls from a hat. I needed a little bit more realism in my quest to understand Bayes Theorem and so I devised the following scenario.

It has taken my small brain months, maybe even years to begin to comprehend Bayes Theorem so don’t be disheartened if you can’t understand this post right away. Keep at it, keep reading, and like me, one day, the truth about our beliefs and the way we form them will dawn on you!!

I have chosen to write this post as a work of fiction rather than a paper on the subject it really addresses. In a nutshell —> Just because your sensor has reported a target detection, it doesn’t mean that there is actually a target there.

Scene 1:

The Starship Enterprise continues on her five year voyage to seek out new life and new civilizations, to boldly go where no man has gone before.

NCC 1701

While en route to the Federation Research Vessel Epsilon-9, the Enterprise is re-directed to protect the cargo carrier Kobiyashi Maru and escort her safely through the outer limits of the Klingon Empire which has been at war with the Federation for several hundred years.

Kobiyashi Maru

Directly threatening the Kobiyashi Maru is a Klingon Bird of Prey, the Devastator lurking somewhere along her flight trajectory. The Kobiyashi Maru, is now stopped and motionless in space as she attempts to repair her warp drive. Intelligence places the Devastator somewhere within a 50 astro-mile radius of this position. The Devastator is equipped with a cloaking device that makes her all but invisible to the human eye.

The Enterprise however, is fitted with a special neutron sensor that can potentially detect a Bird of Prey even when cloaked and invisible.  The sensor works by transmitting bursts of neutrons around the Enterprise, if these neutrons are incident on any sort of cloaking device, they give off a faint radio emission which can be picked up by the Enterprise thereby revealing the direction to and the distance from the cloaked object.

Klingon Bird of Prey Devastator uncloaked and visible to the human eye

From the perspective of Captain Kirk on the Enterprise, the picture looks like this…

Area A1 and A2 with the Maru in the centre. Enterprise is seen randomly searching within Area A1 with a search radius = A2. Enterprise is also blind in the stern sector.

Area A1 is the area within which intelligence has placed the Devastator. This is defined as the Target (Devastator) Probability Area and

A1 = pi * 50  * 50 = 7854 sq astro-miles (We keep our story in 2D for simplicity)

Kirk’s Anti-cloak sensor is capable of searching upto 15 astromiles in radius from the Enterprise without allowing its probability of detection to drop below 0.5.

Area A2 is defined as the Area of Search around the Enterprise and

A2 = pi * 15 * 15 = 706.86 sq astromiles  (We keep our story in 2D for simplicity)

But this sensor is blind towards the rear of the Enterprise due to interference from her own thrusters. There is a blind arc of about 30 degrees on either side of the stern.

Area A1 is reduced by a factor of 60/360 = 589.05 square astro-miles

The Coverage Factor (CF) is defined as the area swept by the searcher (Enterprise) divided by the total target probability area. If we assume that the Devastator (target) is within Area A1, then the numerical value of the CF is also equal to the probability that the Devastator exists within the search zone (green pie shape in the diagram) of the Enterprise (searcher).

For Enterprise, CF = Area A2/ Area A1 = 0.075

Now providing both Enterprise and the Devastator are moving randomly through the Target Probability Area, each searching for their own target, then the following condition is true:

The probability that Enterprise will detect the Devastator = 1 – e^(-CF) = 0.072. This formula can be studied further by looking up this book.

The scene is set.

Scene 2:

The Enterprise‘s Anti-Cloak Sensor has not been performing upto expectations. During early trials, it hardly ever sounded a false alarm but of late, 3 out of every 8 ‘Bird of Prey detections’ has been a false alarm. This high false alarm rate is compounded by radio interference from the nearby Motaro nebula and because the sensor officer, Lt Saavik is exhausted from being overworked at her console.

Probability of False Alarm = 3/8 = 0.375

This is a cause of concern for Captain Kirk who has been firing off photon torpedoes at every single Bird of Prey that has been reported by the Anti-Cloak sensor. He is quickly running out of ammunition and the Kobiyashi Maru is still conducting repairs to her warp drive. He needs a way to determine the likelihood that the Devastator is ACTUALLY within his search zone given that the sensor reports a detection. If he knew this likelyhood, he could save on his ammunition.

Scene 3:

Spock explains Bayes Theorem

Mr. Spock comes to the rescue as usual and breaks down the problem into into its component parts:-

Hypothesis H has been proposed – The Devastator is within the search radius of the Enterprise.

Evidence E has been received – A detection is reported by the Anti-Cloak sensor.

Now, what  Kirk needs to do is determine the likelyhood of H being true given E has occured.

Spock puts this in math terms……We are looking to determine P(H given E has occurred), in math terms, this is equivalent to P(H|E).

Bayes Theorem says

Bayes Theorem

Put simply, the probability that our hypothesis H is true given new evidence E is equal to

(1) The probability of the hypothesis being true multiplied by the probability that evidence E would be observed given that H is true

DIVIDED BY

the sum of (1) and the Probability that our hypothesis H is false multiplied by the Probability that we would see evidence E even if H were false.

Kirk doesn’t quite get this, so Spock elaborates the theory relative to their current predicament….

He says the probability that the Devastator is actually within the Enterprise‘s search radius, given that the Anti-cloak sensor has reported a detection is equal to :

P(Devastator is inside the Search Radius) * P(Detection given Devastator is inside the search radius) —————-> Numerator

DIVIDED BY

P(Devastator is actually outside the search radius) * P(The detection reported by the sensor is due to some other reason, perhaps a false alarm) + numerator

Scene 4:

Lets do the math for Kirk.

P(H) = Devastator is inside the search radius = Coverage Factor = 0.075

P(Detection by the Enterprise given Devastator in inside the search radius) = 0.072

NUMERATOR = 0.075 * 0.072 = 0.0054

P(~H) = Devastator is outside the search radius = 1 – Coverage Factor = 0.925

P(E|~H) = Detection reported even though Devastator is outside the search radius = false alarm rate = 3/8 = 0.375

DENOMINATOR = NUMERATOR + 0.925 * 0.375 = 0.352

Which means P(Devastator is present | Detection is reported) = 0.0153

This is quite a shock to Kirk who until now believed that he stood a 7.2 % (P Det = 0.072) of correctly detecting the Devastator.

Here is the formula in a more relevant format:-

Play around the values A1, A2 and False Alarm rate to see what kind of confidence Kirk can place in his Anti-cloaking sensor, and if the confidence levels are low due to a reduced coverage factor, equipment age, abnormal operating regimes, operator fatigue, environmental interference etc etc, remember to shout Belay That Photon Torpedo Order!!!!!! before Kirk runs out of ammunition.

[EDIT] The astute observer will wonder what happens if A2 >= A1? This would mean that the Devastator is DEFINITELY, WITHOUT ANY DOUBT within the search radius of the Enterprise. The equation would then fail and the resulting conclusion would be gibberish.

This is true, the equation would fail if A2 >= A1, but I think since we are dealing with probabilities, A2 can never be equal to A1 since we can never be ABSOLUTELY, DEFINITELY sure that the Devastator is within the circle that intelligence has reported her to be. This is a fact of life, in the real world, we can never ever be absolutely certain of anything, we can just say that is very very likely. Anyway, that’s what I think is a decent explanation, I may be wrong.

## 5 thoughts on “Belay That Photon Torpedo Order!!!”

1. I may not have understood the math but I loved the way you explained it through the scenario! I have Geek Love.

2. For some unfathomable reason both you and your DW do not enter my gmail box.
I loved the story and the pictures, and I am very happy to know that you find all of the equations completely comprehensible. I used to pride myself on my ability with maths – ooooo so misplaced!!
More power to you!

• hey! glad you liked the story!!!

3. really, for realism u use star trek? and the part that i didnt get was why kirk thought that P Det = 0.072

• P(DET) = 1 – E^(-CF) = 0.072