beginnerstatistics

Probability Basics

The language of uncertainty — how likely is something to happen?

Key Points

What it is

Probability is just a number between 0 and 1 that tells you how likely something is to happen. A 0 means it will never happen. A 1 means it always happens. Everything in between is a maybe. Think of it like a confidence score — when a spam filter says an email is 87% likely to be spam, that's probability at work. Every prediction a data science model makes is really just a probability dressed up as an answer.

Why it exists

Nothing in the real world is 100% certain. A model predicting whether someone will buy a product can't just say yes or no with certainty — it has to say 'there's a 73% chance.' Probability gives us a shared language for talking about uncertainty in a way that's measurable and consistent. Without it, we'd have no way to say how confident a model is, how reliable a test is, or how likely we are to be wrong.

What it measures

Probability measures how often something would happen if you repeated a situation many times. Flip a fair coin 10,000 times and heads shows up about 5,000 times — so the probability is 0.5. In machine learning, it measures how confident a model is. When a model says P(spam) = 0.87, it's saying: out of every 100 emails that look like this, about 87 would actually be spam.

Intuition

Picture a bag with 3 red balls and 7 blue ones. Reach in without looking — you've got a 3 in 10 chance of grabbing red. That's 0.3, or 30%. Now say you pull out a red ball and don't put it back. Now the bag has 2 red and 7 blue — your next chance of pulling red drops to 2 in 9. The situation changed, so the probability changed. This idea of probability updating as you get new information is the whole foundation of Bayesian reasoning, which you'll see come up again in conditional probability.

Example

A spam classifier looks at an email and outputs P(spam) = 0.87.

The model isn't saying 'this is spam.' It's saying 'this looks 87% like spam to me.' Whether it actually gets marked as spam depends on a threshold — usually if P > 0.5, it's flagged. But you can move that threshold. If you're building something where missing a spam email is really costly, you might lower the threshold to 0.3. If false alarms are the bigger problem, raise it to 0.7. The probability gives you flexibility — the threshold is the decision.

Formulas

Basic Probability

P(A)=number of favorable outcomestotal number of outcomesP(A) = \frac{\text{number of favorable outcomes}}{\text{total number of outcomes}}
  • P(A) — the probability of event A — this is what we're trying to find
  • favorable outcomes — the number of ways A can happen
  • total outcomes — every possible thing that could happen — assumes each outcome is equally likely

Complement Rule

P(Ac)=1−P(A)P(A^c) = 1 - P(A)
  • P(Aᶜ) — the probability that A does NOT happen — the opposite of A
  • 1 − P(A) — since all probabilities add up to 1, whatever A doesn't take, the complement gets

Multiplication Rule (Independent Events)

P(A∩B)=P(A)×P(B)P(A \cap B) = P(A) \times P(B)
  • P(A ∩ B) — the probability that both A and B happen
  • P(A) × P(B) — only works when A and B are independent — meaning one happening doesn't change the chances of the other

Addition Rule (Mutually Exclusive Events)

P(A∪B)=P(A)+P(B)P(A \cup B) = P(A) + P(B)
  • P(A ∪ B) — the probability that A or B happens
  • mutually exclusive — A and B can't both happen at the same time — there's no overlap between them

When to use

When not to use

Common mistakes

In practice

Probability is the foundation underneath most of what data science does. Classification models (like logistic regression and Naive Bayes) don't just predict a label — they predict a probability for each class and then pick the most likely one. Hypothesis testing uses probability to decide if a result is real or just noise. When you evaluate a model using ROC curves, AUC, or log-loss, you're really asking: how good are its probability estimates? Getting comfortable with probability is what makes all of those concepts click.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

conditional-probabilitynormal-distributionhypothesis-testingmean-median-modevariance-standard-deviation
Chirp at me!