Counting and Probability for Code

  1. Counting Disjoint Cases

    Add the numbers of outcomes in cases that cover the goal without overlap. Identify double counting before applying the rule.

    Undergraduate
  2. The Multiplication Rule for Successive Choices

    When each allowed first choice has the same number of second choices, the product counts complete ordered outcomes.

    Undergraduate
  3. Ordered Choices Without Replacement

    When selected items cannot be reused, each selection in an ordered sequence reduces the number remaining.

    Undergraduate
  4. Counting Unordered Combinations

    Count selections of distinct items without assigning an order to the chosen group.

    Undergraduate
  5. Pascal's Recursion for Combinations

    Subsets of a specified size can be separated into those containing a distinguished item and those that omit it.

    Undergraduate
  6. When Counting Outcomes Gives a Probability

    Dividing favorable outcomes by a total is valid when the outcomes form a finite set of equally likely possibilities.

    Undergraduate
  7. Using the Complement to Find a Probability

    Finding the probability that an event never happens can be easier than directly counting every way it happens at least once.

    Undergraduate
  8. Conditional Probability as a Restricted Count

    Conditioning restricts attention to outcomes where the supplied event occurred. The original probabilities must be renormalized over that restriction.

    Undergraduate
  9. Independence and Mutual Exclusion

    Independent events satisfy a product rule for their intersection. Disjoint events have no common outcome.

    Undergraduate
  10. Probability in Sampling Without Replacement

    Taking an item out changes the available population and can alter the probability of later draws.

    Undergraduate
  11. Total Probability by Partitioning into Groups

    A total event probability can be computed as a weighted sum of its probabilities within disjoint groups covering the population.

    Undergraduate
  12. Bayes' Rule from a Small Frequency Table

    Bayes' rule reverses a conditional question by recalculating the denominator for the observed result.

    Undergraduate
  13. Expected Value as a Probability-Weighted Average

    An expected value multiplies each numeric outcome by its probability and sums the products.

    Undergraduate
  14. Indicators Turn Event Counts into Sums

    An indicator is one when an event occurs and zero otherwise. Its expectation is exactly that event's probability.

    Undergraduate
  15. Variance Using Two Possible Outcomes

    Variance is the expected squared distance from the mean. Its value can distinguish outcomes with the same average and different spreads.

    Undergraduate
  16. Bounding the Chance of Any of Several Events

    The probability of at least one event is at most the sum of the individual probabilities, whether those events are independent or related.

    Undergraduate
  17. A Small Binomial Probability

    For independent trials with a shared success probability, enumerate each possible choice of successful positions to find the probability of a success count.

    Undergraduate
  18. Expected Waiting Time for Independent Repeated Trials

    With independent repeat trials and fixed success probability, the number of attempts until the first success has a geometric distribution on positive integers.

    Undergraduate
  19. A Random Variable as a Function of Outcomes

    A random variable assigns a number to each underlying outcome. Different outcomes can map to one result.

    Undergraduate
  20. Representing a Discrete Distribution as Probabilities

    A probability mass table associates each possible value with its probability. Entries are nonnegative and sum to one across the support.

    Undergraduate
  21. Sampling with Cumulative Weights

    Nonnegative weights can define consecutive intervals. Draw a uniform position in the total span and choose the interval covering it.

    Undergraduate
  22. When to Enumerate and When to Simulate

    Enumeration can give an exact finite probability. Simulation estimates the result by repeating samples from a defined model.

    Undergraduate
  23. Choosing an Item Uniformly from a List

    Selecting a uniform position gives equal probability to every position. Values repeated at several positions get greater total probability.

    Undergraduate
  24. Estimating a Proportion from Observations

    The observed fraction of successes estimates a probability under a sampling model. It retains information about sample count and variation.

    Undergraduate
  25. Combining Group Rates with Unequal Sizes

    Combine each group's numerator and denominator, or weight its rate by its size. The mean of rates answers a different weighting question.

    Undergraduate
  26. Why Collision Opportunities Grow with the Number of Pairs

    Each pair of independent uniform labels has a chance to match. The count of pairs grows faster than the count of labels drawn.

    Undergraduate
  27. Counting Strings Over a Finite Alphabet

    A string's positions give ordered choices. Constraints on length, repetition, or required symbols change the count.

    Undergraduate
  28. Counting Shortest Monotone Grid Paths

    A path taking only right and down steps is determined by the positions of one kind of step in its ordered move list.

    Undergraduate
  29. Deterministic Replay of a Random Experiment

    A recorded seed and a compatible generator can reproduce a pseudo-random sequence. The sequence of calls matters as much as the seed.

    Undergraduate
  30. Sample Size and Apparent Fairness

    A small run of a fair process can produce counts that look unequal. A useful check describes what variation the assumed process predicts.

    Undergraduate