Good to see you again. In the previous lesson, you summarized numerical speech-data properties with means, variances, and covariances. Those are descriptive tools: they tell you what a dataset looks like. This lesson moves to uncertainty about an individual example: given some evidence, how should a classifier’s belief change?
Conditional probability and Bayes’ rule are especially important whenever an apparently convincing signal is rare in real traffic. A speech-activity detector may flag audio as containing speech; a quality-control system may flag a clipped recording; a wake-word detector may trigger. The operational question is often not “how often does the detector fire when the condition is present?” but rather “when it fires, how likely is the condition actually present?”
By the end, you will be able to distinguish those questions, calculate conditional probabilities, and use Bayes’ rule to obtain a posterior class probability.
Conditional probability: restrict the population first
Let and be events. The notation
is read as “the probability of , given .” The vertical bar means that we already know occurred.
The key move is to restrict the population to cases where is true. Among that reduced population, ask what fraction also belongs to .
Formally, provided that ,
Here, means that both events occur.
Suppose a batch contains audio clips:
- contain speech.
- are recorded on a mobile device.
- both contain speech and were recorded on a mobile device.
The unconditional probability that a randomly selected clip contains speech is
But if you already know that the clip was recorded on a mobile device, the relevant population has only clips. Of those, contain speech:
The condition changes the denominator. It does not merely add another fact to a sentence.
Conditional Probabilities, Clearly Explained!!!
Watch Conditional Probabilities, Clearly Explained!!! from StatQuest with Josh Starmer for a visual treatment of the “restricted population” idea.
Watch the visual setup. The first segment introduces the condition; the second shows how the denominator becomes the subset selected by that condition. Focus on identifying the reduced sample space before doing any division.
Conditional probabilities are directional
A common and consequential error is to reverse the condition:
in general.
For the audio example,
but
Both calculations use the same overlap of clips, but they answer different questions and use different denominators.
This distinction becomes central in classification:
| Quantity | What it asks |
|---|---|
| If the true condition exists, how often does the system flag it? | |
| If the system flags it, how likely is the true condition? |
The first is a property of the system’s behavior on a known class. The second is the probability an operator or downstream system usually needs after observing the flag.
Bayes’ rule: reversing a conditional probability
Bayes’ rule relates these two directions. Start with the joint probability that both and occur:
We can write the same joint probability in the other direction:
Since both expressions describe the same joint event,
Dividing by gives Bayes’ rule:
The terms have useful names:
- The prior is the probability of the class before observing the evidence.
- The likelihood describes how compatible the observed evidence is with that class.
- The posterior is the updated probability after observing the evidence.
- The evidence normalizes the result so that the posterior is a valid probability.
For a two-class problem, where and are mutually exclusive and cover all possibilities, the evidence is found with the law of total probability:
Substituting this into Bayes’ rule produces the version most useful for a binary classification calculation:
Bayes' Theorem, Clearly Explained!!!!
In Bayes' Theorem, Clearly Explained!!!!, StatQuest derives Bayes’ rule from the two equivalent ways to express a joint probability.
Watch the derivation. Notice that the shared numerator is the probability of both events occurring; Bayes’ rule becomes valuable when that joint probability is not directly available.
A classification calculation with natural counts
Consider a hypothetical speech-activity flagger operating on short windows from an always-on audio stream. Let:
- : the window truly contains speech.
- : the system flags the window as speech.
Suppose the deployment environment has these properties:
so only of windows actually contain speech.
The system detects of true speech windows:
But it also incorrectly flags of non-speech windows:
The question after the system fires is:
It is tempting to answer , but is , not . It tells us about the flagger’s response to known speech, not about the composition of all flagged windows.
Natural counts make the calculation concrete. Imagine incoming audio windows.
- Since speech occurs in of windows, windows contain speech.
- The other windows contain no speech.
- The flagger catches of the true-speech windows, producing true positives.
- It incorrectly flags of the non-speech windows, producing false positives.

Among all flagged windows, there are
flags. Only correspond to actual speech. Therefore,
So the posterior probability is about :
The same result follows directly from Bayes’ rule:
Substitute the given probabilities:
The low posterior does not mean the flagger has no value. Before the flag, the chance of speech was only . After a flag, it is about , a substantial update. But it may still be too uncertain to trigger an expensive downstream ASR model without additional filtering or a higher decision threshold.
The base-rate effect in speech systems
Why does a detector with a true-positive rate produce only a probability after firing?
The answer is the base rate, also called prevalence or prior probability:
There are very few real speech windows relative to non-speech windows. Even a modest false-positive rate applied to the large non-speech population creates many false positives.
In the example:
| Outcome | Count | Interpretation |
|---|---|---|
| True positive | Speech is present and the system flags it. | |
| False negative | Speech is present but the system does not flag it. | |
| False positive | No speech is present but the system flags it. | |
| True negative | No speech is present and the system does not flag it. |
Two useful measurements arise from this table:
is the true-positive rate, often called recall or sensitivity.
is the positive predictive value, commonly called precision.
They are not interchangeable. In real speech products, precision depends not only on model behavior but also on the traffic mix. A wake-word model tested on a carefully constructed benchmark may encounter a much higher rate of actual wake words than it will in a live always-listening environment. Its deployment precision can therefore be substantially lower than expected.
This is why evaluation data should resemble the deployment context. A prior estimated from one population may be unsuitable for another:
- A call-center recording stream may have speech in most windows.
- A voice-assistant stream may contain long periods of silence, music, TV audio, and background noise.
- An audio-quality triage system may see rare clipping failures in normal operation but many failures in a deliberately enriched test set.
Bayes’ rule makes the dependency explicit rather than hiding it behind one headline metric.
A reliable calculation template
For a binary classification question of the form “What is the probability of class , given observed signal ?”, use this procedure.
-
Define the events in words.
State clearly which event is the class and which is the observation. For example, can mean “the clip has clipping,” while can mean “the quality model raises an alert.” -
Write the requested probability before inserting numbers.
- Identify the three needed inputs.
- Calculate the complementary prior.
- Compute the evidence using both ways that can occur.
- Divide the class-and-evidence probability by the total evidence probability.
A short Python implementation makes the denominator explicit:
def posterior_given_positive(prior, true_positive_rate, false_positive_rate):
"""Return P(class | positive_flag) for a binary classifier."""
p_class = prior
p_not_class = 1 - prior
true_positive_probability = true_positive_rate * p_class
false_positive_probability = false_positive_rate * p_not_class
p_positive_flag = true_positive_probability + false_positive_probability
return true_positive_probability / p_positive_flag
posterior = posterior_given_positive(
prior=0.02,
true_positive_rate=0.90,
false_positive_rate=0.10,
)
print(f"{posterior:.3f}")
# 0.155
The names matter. Calling every probability “accuracy” is a frequent source of mistakes. In particular, ensure that the numerator represents the exact joint event in the question: class present and flag observed.
Common failure modes
Reversing the conditional
Do not replace
with
The two may differ dramatically when the class is rare.
Ignoring false positives
Using only and gives the true-positive probability:
It does not answer the posterior question because it ignores the other route to a flag:
Using an irrelevant prior
The prior should describe the population to which the inference applies. If a model is deployed in a new language, acoustic domain, or product flow, the rate of the target event may change. A posterior calculated with the old rate can be misleading even if the detector itself has not changed.
Treating a posterior as a decision rule by itself
A posterior is an estimate of uncertainty. Whether to act also depends on the costs of errors. For example, sending every flagged audio window to a costly ASR service may require a much higher posterior than routing it to a cheap secondary detector. Later modules will connect these probabilities to model evaluation, thresholds, and system-level costs.
Key takeaways
Conditional probability narrows the population to cases satisfying the condition:
The order of conditioning matters:
in general.
Bayes’ rule reverses a conditional relationship:
For binary classification, compute the evidence by considering both the true-class and non-class ways that an observed flag can occur:
Most importantly, a model’s true-positive rate is not the probability that an example is truly positive after the model fires. That posterior depends strongly on the base rate in the deployment population.
Next, you will use logarithms and log probabilities. This will prepare you for the extremely small probability products that occur in ML models and speech sequence decoding.
Can't find a good explanation? Sign up and we'll make it for you
Sign up