SlideShare a Scribd company logo
1 of 12
Download to read offline
Bayes' Theorem




For programmers
Joke
●   What's the difference between a
    mathematician, an engineer and a
    programmer?
Punchline
●   Mathematicians use natural log (base e)
●   Engineers use decibels (10 times log base
    10)
●   Programmers use bits (log base 2)
Useful functions
●   odds(p)=p/(1-p)
        –   Gambler talk: 1/3 → “1-to-2”
●   logit(p)=log(odds(p))
        –   Remember: logs are base 2, or bits
●   expit(p)=exp(p/(1+p))
        –   Inverse of logit
What is belief?
●   Belief(X) = logit(Probability you assign to X)
        –   Measured in bits
●   Fun fact: Belief(not X)=-Belief(X)
Examples
●   Belief(X)=0: probability 0.5, zero
    knowledge
●   Belief(X)=1: probability is 2/3
●   Belief(X)=-1: probability is 1/3
●   Belief(X)=5: probability about 0.97
More examples
●   Belief(X)=10: “I’m 99.9% certain about
    this!”
●   Belief(X)=-10: “There’s a 0.001 chance of
    that!”
●   Belief(X)=infinity: probability 1, or “The
    religious belief”…
Accuracy of belief
●   Overconfidence: >>1-expit(B) of beliefs of
    strength >B are wrong (for some B>0)
●   Underconfidence: <<1-expit(B) of beliefs
    of 0<strength<B are wrong (for some B>0)
●   Well-calibrated: Neither overconfident nor
    underconfident
Evidence
●   Event E happened. Is X true?
●   E is helpful only when P(E given X) != P(E
    given not X). But how much?
●   Likelihood(E given X) = P(E given X)/P(E
    given not X)
●   Evidence(E about X) = log(Likelihood(E
    given X))
●   Evidence is measured in bits!
THE FORMULA




  Belief(X after seeing E) =
Belief(X)+Evidence(E about X)
Bayes' Theorem
●   “If you are well-calibrated, and update
    beliefs according to THE FORMULA, you
    remain well-calibrated”
●   Corrolary: If you sometimes count evidence
    twice, or sometimes only weakly, you FALL
    OUT OF CALIBRATION!
Remember, Kids!



Bayes’ Theorem is math, not a suggestion.
       If you care about being right,
        you can’t afford to ignore it!

More Related Content

Similar to Bayes' Theorem for Programmers (12)

Naive Bayes
Naive Bayes Naive Bayes
Naive Bayes
 
Lec12-Probability (1).ppt
Lec12-Probability (1).pptLec12-Probability (1).ppt
Lec12-Probability (1).ppt
 
Lec12-Probability.ppt
Lec12-Probability.pptLec12-Probability.ppt
Lec12-Probability.ppt
 
Lec12-Probability.ppt
Lec12-Probability.pptLec12-Probability.ppt
Lec12-Probability.ppt
 
Lec12-Probability.ppt
Lec12-Probability.pptLec12-Probability.ppt
Lec12-Probability.ppt
 
Bayes 6
Bayes 6Bayes 6
Bayes 6
 
Lecture3
Lecture3Lecture3
Lecture3
 
Random Variables
Random VariablesRandom Variables
Random Variables
 
Recitation decision trees-adaboost-02-09-2006-3
Recitation decision trees-adaboost-02-09-2006-3Recitation decision trees-adaboost-02-09-2006-3
Recitation decision trees-adaboost-02-09-2006-3
 
NaiveBayes.ppt
NaiveBayes.pptNaiveBayes.ppt
NaiveBayes.ppt
 
NaiveBayes.ppt
NaiveBayes.pptNaiveBayes.ppt
NaiveBayes.ppt
 
NaiveBayes.ppt
NaiveBayes.pptNaiveBayes.ppt
NaiveBayes.ppt
 

Recently uploaded

Russian Call Girls Lucknow Just Call 👉👉 📞 8617370543 Top Class Call Girl Serv...
Russian Call Girls Lucknow Just Call 👉👉 📞 8617370543 Top Class Call Girl Serv...Russian Call Girls Lucknow Just Call 👉👉 📞 8617370543 Top Class Call Girl Serv...
Russian Call Girls Lucknow Just Call 👉👉 📞 8617370543 Top Class Call Girl Serv...
Nitya salvi
 
Call Girls In Sindhudurg Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service E...
Call Girls In Sindhudurg Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service E...Call Girls In Sindhudurg Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service E...
Call Girls In Sindhudurg Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service E...
Nitya salvi
 
Nehru Nagar, Call Girls ☎️ ((#9711106444)), 💘 Full enjoy Low rate girl💘 Genui...
Nehru Nagar, Call Girls ☎️ ((#9711106444)), 💘 Full enjoy Low rate girl💘 Genui...Nehru Nagar, Call Girls ☎️ ((#9711106444)), 💘 Full enjoy Low rate girl💘 Genui...
Nehru Nagar, Call Girls ☎️ ((#9711106444)), 💘 Full enjoy Low rate girl💘 Genui...
delhimunirka15
 
一比一原版(UofG学位证书)圭尔夫大学毕业证学历认证快速办理
一比一原版(UofG学位证书)圭尔夫大学毕业证学历认证快速办理一比一原版(UofG学位证书)圭尔夫大学毕业证学历认证快速办理
一比一原版(UofG学位证书)圭尔夫大学毕业证学历认证快速办理
txkonu
 
Museum of fine arts Lauren Simpson…………..
Museum of fine arts Lauren Simpson…………..Museum of fine arts Lauren Simpson…………..
Museum of fine arts Lauren Simpson…………..
mvxpw22gfc
 
Van Gogh Powerpoint for art lesson today
Van Gogh Powerpoint for art lesson todayVan Gogh Powerpoint for art lesson today
Van Gogh Powerpoint for art lesson today
lucygibson17
 
architect Hassan Khalil portfolio Year 2024
architect Hassan Khalil portfolio  Year 2024architect Hassan Khalil portfolio  Year 2024
architect Hassan Khalil portfolio Year 2024
hassan khalil
 
WhatsApp-(# 9711106444 #)Call Girl in Noida Sector 80 Noida (Escorts) Delhi
WhatsApp-(# 9711106444 #)Call Girl in Noida Sector 80 Noida (Escorts) DelhiWhatsApp-(# 9711106444 #)Call Girl in Noida Sector 80 Noida (Escorts) Delhi
WhatsApp-(# 9711106444 #)Call Girl in Noida Sector 80 Noida (Escorts) Delhi
delhimunirka15
 
一比一原版(YU学位证书)约克大学毕业证学历认证新版办理
一比一原版(YU学位证书)约克大学毕业证学历认证新版办理一比一原版(YU学位证书)约克大学毕业证学历认证新版办理
一比一原版(YU学位证书)约克大学毕业证学历认证新版办理
txkonu
 
一比一原版(UEA毕业证书)东英吉利亚大学毕业证如何办理
一比一原版(UEA毕业证书)东英吉利亚大学毕业证如何办理一比一原版(UEA毕业证书)东英吉利亚大学毕业证如何办理
一比一原版(UEA毕业证书)东英吉利亚大学毕业证如何办理
ss
 

Recently uploaded (20)

Turn Off The Air Con - The Singapore Punk Scene
Turn Off The Air Con - The Singapore Punk SceneTurn Off The Air Con - The Singapore Punk Scene
Turn Off The Air Con - The Singapore Punk Scene
 
Call Girls In Firozabad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Firozabad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...Call Girls In Firozabad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Firozabad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
 
Russian Call Girls Lucknow Just Call 👉👉 📞 8617370543 Top Class Call Girl Serv...
Russian Call Girls Lucknow Just Call 👉👉 📞 8617370543 Top Class Call Girl Serv...Russian Call Girls Lucknow Just Call 👉👉 📞 8617370543 Top Class Call Girl Serv...
Russian Call Girls Lucknow Just Call 👉👉 📞 8617370543 Top Class Call Girl Serv...
 
Call Girls In Sindhudurg Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service E...
Call Girls In Sindhudurg Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service E...Call Girls In Sindhudurg Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service E...
Call Girls In Sindhudurg Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service E...
 
Nehru Nagar, Call Girls ☎️ ((#9711106444)), 💘 Full enjoy Low rate girl💘 Genui...
Nehru Nagar, Call Girls ☎️ ((#9711106444)), 💘 Full enjoy Low rate girl💘 Genui...Nehru Nagar, Call Girls ☎️ ((#9711106444)), 💘 Full enjoy Low rate girl💘 Genui...
Nehru Nagar, Call Girls ☎️ ((#9711106444)), 💘 Full enjoy Low rate girl💘 Genui...
 
一比一原版(UofG学位证书)圭尔夫大学毕业证学历认证快速办理
一比一原版(UofG学位证书)圭尔夫大学毕业证学历认证快速办理一比一原版(UofG学位证书)圭尔夫大学毕业证学历认证快速办理
一比一原版(UofG学位证书)圭尔夫大学毕业证学历认证快速办理
 
How to order fake Worcester State University diploma?
How to order fake Worcester State University diploma?How to order fake Worcester State University diploma?
How to order fake Worcester State University diploma?
 
SB_ Scott Pilgrim_ Rough_ RiverPhan (2024)
SB_ Scott Pilgrim_ Rough_ RiverPhan (2024)SB_ Scott Pilgrim_ Rough_ RiverPhan (2024)
SB_ Scott Pilgrim_ Rough_ RiverPhan (2024)
 
Museum of fine arts Lauren Simpson…………..
Museum of fine arts Lauren Simpson…………..Museum of fine arts Lauren Simpson…………..
Museum of fine arts Lauren Simpson…………..
 
Jaunpur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Jaunpur
Jaunpur Escorts Service Girl ^ 9332606886, WhatsApp Anytime JaunpurJaunpur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Jaunpur
Jaunpur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Jaunpur
 
Van Gogh Powerpoint for art lesson today
Van Gogh Powerpoint for art lesson todayVan Gogh Powerpoint for art lesson today
Van Gogh Powerpoint for art lesson today
 
Ignite Your Brand: Tailored Creative Solutions Proposal
Ignite Your Brand: Tailored Creative Solutions ProposalIgnite Your Brand: Tailored Creative Solutions Proposal
Ignite Your Brand: Tailored Creative Solutions Proposal
 
architect Hassan Khalil portfolio Year 2024
architect Hassan Khalil portfolio  Year 2024architect Hassan Khalil portfolio  Year 2024
architect Hassan Khalil portfolio Year 2024
 
HUMA Final Presentation About Chicano Culture
HUMA Final Presentation About Chicano CultureHUMA Final Presentation About Chicano Culture
HUMA Final Presentation About Chicano Culture
 
WhatsApp-(# 9711106444 #)Call Girl in Noida Sector 80 Noida (Escorts) Delhi
WhatsApp-(# 9711106444 #)Call Girl in Noida Sector 80 Noida (Escorts) DelhiWhatsApp-(# 9711106444 #)Call Girl in Noida Sector 80 Noida (Escorts) Delhi
WhatsApp-(# 9711106444 #)Call Girl in Noida Sector 80 Noida (Escorts) Delhi
 
一比一原版(YU学位证书)约克大学毕业证学历认证新版办理
一比一原版(YU学位证书)约克大学毕业证学历认证新版办理一比一原版(YU学位证书)约克大学毕业证学历认证新版办理
一比一原版(YU学位证书)约克大学毕业证学历认证新版办理
 
sources of Hindu law kdaenflkjwwfererger
sources of Hindu law kdaenflkjwwferergersources of Hindu law kdaenflkjwwfererger
sources of Hindu law kdaenflkjwwfererger
 
Jaro je tady - Spring is here (Judith) 4
Jaro je tady - Spring is here (Judith) 4Jaro je tady - Spring is here (Judith) 4
Jaro je tady - Spring is here (Judith) 4
 
Theoretical Framework- Explanation with Flow Chart.docx
Theoretical Framework- Explanation with Flow Chart.docxTheoretical Framework- Explanation with Flow Chart.docx
Theoretical Framework- Explanation with Flow Chart.docx
 
一比一原版(UEA毕业证书)东英吉利亚大学毕业证如何办理
一比一原版(UEA毕业证书)东英吉利亚大学毕业证如何办理一比一原版(UEA毕业证书)东英吉利亚大学毕业证如何办理
一比一原版(UEA毕业证书)东英吉利亚大学毕业证如何办理
 

Bayes' Theorem for Programmers

  • 2. Joke ● What's the difference between a mathematician, an engineer and a programmer?
  • 3. Punchline ● Mathematicians use natural log (base e) ● Engineers use decibels (10 times log base 10) ● Programmers use bits (log base 2)
  • 4. Useful functions ● odds(p)=p/(1-p) – Gambler talk: 1/3 → “1-to-2” ● logit(p)=log(odds(p)) – Remember: logs are base 2, or bits ● expit(p)=exp(p/(1+p)) – Inverse of logit
  • 5. What is belief? ● Belief(X) = logit(Probability you assign to X) – Measured in bits ● Fun fact: Belief(not X)=-Belief(X)
  • 6. Examples ● Belief(X)=0: probability 0.5, zero knowledge ● Belief(X)=1: probability is 2/3 ● Belief(X)=-1: probability is 1/3 ● Belief(X)=5: probability about 0.97
  • 7. More examples ● Belief(X)=10: “I’m 99.9% certain about this!” ● Belief(X)=-10: “There’s a 0.001 chance of that!” ● Belief(X)=infinity: probability 1, or “The religious belief”…
  • 8. Accuracy of belief ● Overconfidence: >>1-expit(B) of beliefs of strength >B are wrong (for some B>0) ● Underconfidence: <<1-expit(B) of beliefs of 0<strength<B are wrong (for some B>0) ● Well-calibrated: Neither overconfident nor underconfident
  • 9. Evidence ● Event E happened. Is X true? ● E is helpful only when P(E given X) != P(E given not X). But how much? ● Likelihood(E given X) = P(E given X)/P(E given not X) ● Evidence(E about X) = log(Likelihood(E given X)) ● Evidence is measured in bits!
  • 10. THE FORMULA Belief(X after seeing E) = Belief(X)+Evidence(E about X)
  • 11. Bayes' Theorem ● “If you are well-calibrated, and update beliefs according to THE FORMULA, you remain well-calibrated” ● Corrolary: If you sometimes count evidence twice, or sometimes only weakly, you FALL OUT OF CALIBRATION!
  • 12. Remember, Kids! Bayes’ Theorem is math, not a suggestion. If you care about being right, you can’t afford to ignore it!