PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

AI · Theory

Bayes Theorem

← All stacks

Theory

45/215

Bayes Theorem

Bayes: P(H|E) = P(E|H) P(H) / P(E). Prior P(H), likelihood P(E|H), posterior P(H|E). Spam: H = spam, E = word “lottery”. A rare disease with a pretty-good test still has a modest posterior if the prior is tiny — classic trap.

Always name prior, likelihood, posterior. Plug tiny numbers if they ask to compute. Don’t recite the formula with no story.

Bayes Theorem — output — 0.8. After seeing lottery, spam belief jumps from 0.2 to 0.8.

Diagram
prior P(H)
       × P(E|H)
       / P(E)
       ▼
  posterior P(H|E)
Exam tip

Spam or disease story + name the three terms.

Example

# Bayes — lottery word
# P(spam)=0.2  P(lottery|spam)=0.8  P(lottery|ham)=0.05
# P(lottery)=0.8*0.2 + 0.05*0.8 = 0.20
p_spam_given_lottery = (0.8 * 0.2) / 0.20
print(round(p_spam_given_lottery, 2))

Bayes Theorem — output: 0.8. After seeing lottery, spam belief jumps from 0.2 to 0.8.

Short notes

  • P(H|E) = P(E|H)P(H)/P(E)
  • Prior / likelihood / posterior
  • Trapignoring the prior.

Questions

1

Explain Bayes Theorem as if you are teaching a junior — definition, then one example.

2

What does the example print, and what does that prove?

3

What mistake do freshers make with Bayes Theorem?

Previous← Probabilistic ReasoningNextBayesian Belief Network →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.