Probability Playground

CS203 · Mohammad Sabokrou · New Uzbekistan University

If the controls do not respond, download this HTML file and open it in Chrome or Edge. This file preview may block interactive scripts.
1 / 17 · Lecture slides 1–5
Motivation

The data science question

A message arrives with an unknown label. How should evidence change our belief about its class?

The observed message

Off means the feature is known to be absent. It does not mean the feature is ignored.


“Special offer.
Follow this link.”

A synthetic classifier has two possible labels: spam and regular.

Spam: 88.24%Regular: 11.76%
P(spam | features)88.24%
PredictionSpam
P(C | evidence) = prior × likelihoodsum of class scores
Try in class

Hide the answers. What should happen if the message contains “offer”, but no link? Will the more common class always win?

Probability lets us combine class frequencies with feature evidence. A predicted class and a posterior probability answer different questions. The classifier section shows every training count and factor.

Classroom guide

Use Prediction pause before asking a question. Change the inputs, ask for a prediction, then reveal the numbers. Classroom view hides the sidebar and enlarges the demonstration. Every section also has a reset button.

DemonstrationLecture slides
1. Why probability?1–5
2. Dice & probability6–7, 10–11
3. The three axioms8–9
4. Event rules12–14
5. Random variables15–19, 62–63
6. Simulation21–24, 59
7. Continuous density19–20, 65
8. Bernoulli & binomial63–64
9. Conditional probability25–29, 60
10. Independence30
11. Two bags & Bayes32–44, 61, 72–73
12. Base rates70–71
13. Naive Bayes45–58
14. Multiple classes67
15. Gaussian features66
16. Smoothing & log scores68–69
17. Class challenges31, 58, 74–76

Mathematical conventions

All training data, bags and factory examples are synthetic. Probabilities depend on the stated model. An event with probability zero cannot be used as a conditioning denominator in these finite examples. In a continuous model, individual points can have probability zero while nearby intervals have positive probability.

The fair-die simulation uses the same MT19937 integer seeding and rejection sampling as Python random.Random(seed).randint(1,6) for non-negative 32-bit integer seeds. Seed 9 reproduces the lecture counts. Weighted draws use inverse-CDF sampling from the same generator.

Normal interval probabilities use a numerical error-function approximation, accurate to about 10−7 in absolute probability. Plotted curves use finite samples. The numerical probability comes from the CDF, rather than from counting pixels.

Reading

The file has no external scripts, fonts, analytics, or network requirements. Reading links open separately and require internet.