// PROBABILITY · INTERMEDIATE
Probability BasicsSample spaces, events, conditional probability, Bayes' theorem, and expected value — the foundation of probabilistic reasoning.
Prerequisites: Permutations & Combinations · Basic counting
// DICE DISTRIBUTION
Visualize dice probabilities
Adjust the number of dice and target sum to see the probability distribution update in real time.
P(sum = 7) = 6 / 36 = 16.67%
// KEY FORMULAS
Core probability rules
Classical Probability
P(E) = |favorable| / |sample space|
For equally likely outcomes
Complement Rule
P(not E) = 1 - P(E)
The complement of an event
Addition Rule
P(A or B) = P(A) + P(B) - P(A and B)
Union of two events
Conditional Probability
P(A | B) = P(A and B) / P(B)
Probability of A given B
Bayes' Theorem
P(A|B) = P(B|A) · P(A) / P(B)
Update beliefs with evidence
Binomial Distribution
P(k|n) = C(n,k) · pᵏ · (1-p)ⁿ⁻ᵏ
k successes in n trials
// ALGORITHM
Computing binomial probabilities mod p
Precompute factorials and modular inverses to evaluate C(n, k) mod p in O(1) per query.
Press PLAY to step through the algorithm line by line.
// INTERACTIVE GAME
Probability Predictor
Given a probability question, pick the correct percentage. Test your intuition!
Probability Predictor
Estimate the probability as a percentage
You'll be shown a probability question. Pick the correct percentage!
// FLOWCHART
Solving probability problems
Press PLAY to trace the algorithm through the flowchart.
// TUTORIAL QUIZZES
Test your mastery
From basic probability to Bayes' theorem and binomial distributions.
// PRACTICE & ASSESS
Test your understanding
Now that you've learned the concept, put it into practice. Solve coding problems and take quizzes to reinforce what you've learned.
// REFERENCES
Sources & further reading
- [1]A First Course in ProbabilitySheldon Ross — classic probability textbook
- [2]Probability and StatisticsMorris H. DeGroot & Mark J. Schervish — comprehensive reference
- [3]Introduction to ProbabilityJoseph K. Blitzstein & Jessica Hwang — with applications
- [4]The Art of Computer Programming, Vol. 2Donald E. Knuth — random numbers and probability
// READY?
Encode sequences with generating functions
Next up: Generating Functions — transform counting problems into algebraic manipulations of power series.