A Programmer’s Regret: Neglecting Math at University – Adenoid Adventures

Advanced Programming needs Advanced Math: eg.

Video Game Animation: Verlet Integration

AI: Stats, Probability, Calculus, Linear Algebra

Search Engine : PageRank: Linear Algebra

Abstraction in Program “Polymorphism” : Monoid, Category, Functor, Monad

Program “Proof” : Propositions as Types, HoTT


Abstraction: Monoid, Category


9/11 Terror Attack Probability

By Bayes’s Theorem

1. First WTC (World Trade Center) Attack:

Prior Probability
Initial estimate that terrorists would crash planes into Manhattan skyscrapers = 1/20,000 = x = 0.005%

New Event: 1st Plane hits WTC
Probability of plane hitting if terrorists are attacking Manhattan skyscrapers = y = 100%

Probability of plane hitting if terrorists are NOT attacking Manhattan skyscrapers (ie accident) = z = 2 cases in last 25,000 days (once in 1945, another in 1946) = 1/12,500 = 0.008%

Posterior Probability
Revised estimate of probability of terror attack, given first plane hitting WTC =
\displaystyle\boxed{ \frac{xy}{xy+z(1-x)} = 38\%}

2. Second WTC Attack

Now 38% becomes the prior probability = x
y, z remain the same.

Reapply the Bayes’s Theorem:

Posterior Probability
Revised estimate of probability of terror attack, given 2nd plane hitting WTC =
\displaystyle\boxed{ \frac{xy}{xy+z(1-x)} = 99.99\%}

There was a 18-minute interval between the first and the second attack. If someone who had calculated the Bayesian Math to predict 99.99% chance of the would-be second attack, the entire people on the second building could have been evacuated right after the first tower attack, instead of being advised naively (0.01% chance it was safe) to return to their office in the second tower !

You can say this is déjà-vu, but it is Math which could have saved thousands of life on that tragic day of 9/11.

Watch this disturbing documentary video of the 9/11 Attack:

Probability by 2 Great Friends

Today Probability is a “money” Math, used in Actuarial Science, Derivatives (Options) in Black-Scholes Formula.

In the beginning it was “A Priori” Probability by Pascal (1623-1662), then Fermat (1601-1665) invented today’s “A Posteriori” Probability.

“A Priori” assumes every thing is naturally “like that”: eg. Each coin has 1/2 chance for head, 1/2 for tail. Each dice has 1/6 equal chance for each face (1-6).

“A Posteriori” by Fermat, then later the exile Protestant French mathematician De Moivre (who discovered Normal Distribution), is based on observation of “already happened” statistic data.

Cardano (1501-1576) born 150 years earlier than Pascal and Fermat, himself a weird genius in Medicine, Math and an addictive gambler, found the rule of + and x for chances (he did not know the name ‘Probability’ then ):

Addition + Rule: throw a dice, chance to get a “1 and 2” faces:
1/6 +1/6 = 2/6 = 1/3
(Correct: 1 & 2 out of other six faces)

Multiplication x Rule: throw two dices, chance to get a “1 followed by a 2 ” faces : 1/6 x 1/6 = 1/36
(Assume 1st throw does not affect or influence the 2nd throw: independent events)

Pascal never met Fermat personally, only through correspondences (like emails today), but Pascal regarded with respect Fermat as superior in Math than himself.

Fermat and Descartes were not so. Descartes openly criticized Fermat as a second class mathematician. Both independently discovered Analytical Geometry, but Descartes scored the credit in ‘Cartesian’ coordinates.

Fermat never published any books in Math. As a successful judge in Toulous, he spent his free time as an amateur mathematician, especially in Number Theory. He showed his Math discoveries to friends in letters but never provided proofs. Hence the Fermat’s Last Theorem made the world mathematicians after him (Gauss, Euler, Kummer, Sophie Germaine, Andrew Wiles…) busy for 380 years until 1994.

Fermat died 3 years after Pascal. Another Modern Mathematics was being born – Calculus – in UK by Newton and Germany by Leibniz. Probability was put in the back seat over-taken by Calculus.

SARS Suspects

SARS Probability

A group of tourists at airport are screened for temperature twice thru Gate A (accuracy a=98%), then Gate B (accuracy b=97%).

Finding: Gate A detected 32 (=A) tourists, but Gate B only 23 (=B), of which 16(=C) are common.

Q: How many suspects missed out (suspects missed) ?


Let T = Total tourists

a, b the probability of successful detection at Gate A, B, resp.

A=aT , B=bT


C= a.bT (because Gates A, B independent screening)



Suspects-detected= A + B – C (exclude duplicate common)

Suspects-missed M = T- (A+B-C) = AB/C -(A+B-C) =(AB-AC-BC+C.C)/C= (A-C)(B-C)/C

M =(A-C)(B-C)/C

Note: M independent of a, b !!

Suspects-missed M = (32-16)(23-16)/16 = 16×7/16 = 7 [QED]