Skip to main content
AP CSP course

C45 · Topic 3.15 · 40 minutes · AAP-3.E

Count equally likely outcomes

By the end you can:

  • Count all inclusive integer outcomes.
  • Map a condition to a precise event probability.
  • Distinguish an expected count from a guaranteed result.

Before this lesson: topics 3.3, 3.6, 3.8.

Random integer
An integer selected from a stated range by a random process.
Expected frequency
The long-run average count predicted by a probability model, not a guarantee for a particular run.

Understand

In AP CSP, RANDOM(a,b) returns an integer from a through b, inclusive, with each integer equally likely. There are b−a+1 possible values. A condition can group several values into one outcome; count how many values satisfy it.

For RANDOM(1,6), testing roll ≤ 2 succeeds on 1 and 2, giving probability 2/6=1/3. A run of six calls does not guarantee exactly two successes. Random selection is not the same as cycling once through each value.

Worked example

A fictional prize machine uses r ← RANDOM(1,10). Gold if r ≤ 2; otherwise silver if r ≤ 5; otherwise bronze.

  1. Gold:1,2 →2/10.
  2. Silver:3,4,5 →3/10, because the gold branch was not taken.
  3. Bronze:6,7,8,9,10 →5/10. Branch order matters.

Explore each concept

Choose a concept, change its inputs and follow the explanation. Each example models the stated rule or scenario; completing it is practice rather than evidence of mastery.

  • Inclusive integer bounds
  • Exact event probability
  • Expected count is not a guarantee
Open this example on its own

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to explore: Inclusive random ranges and expected outcomes
  1. Lower bound (0–10)2Waiting
  2. Upper bound (0–10)6Waiting
  3. Success at or below (0–10)3Waiting

Ready to explore: Inclusive random ranges and expected outcomes

Why: Change an input, predict the first effect, then advance one step.

Try this: Change one input or choose another listed case. Predict the effect, reset and compare the states and governing rule.

Step through and experiment

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 13Waiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Try thresholds 0 and 10. The supplied stream is deterministic, not randomly regenerated.

Check a misconception

Claim: RANDOM(1,10) has nine possible values.

Both endpoints are included, so count 10−1+1=10.

Guided practice

Choose a RANDOM call and condition giving an event probability 3/8, and list the successful integers.

Work with a partner. Make a prediction, compare your reasoning, then identify the rule that supports your answer.

Independent transfer

A student uses RANDOM(0,10) < 3 for a 30% event. Explain the error and repair it.

Exit check

Must an event with probability 1/2 occur 50 times in 100 independent trials?

Write your reasoning before comparing with a classmate. If your teacher assigned this task, submit it through My classes to save your work and receive feedback.

Check yourself

  1. Question 1 of 2What is the probability RANDOM(2,7) returns a value greater than 5?

    Select one answer.

  2. Question 2 of 2Which TWO expressions each produce true with probability 1/4?

    Select exactly two answers (0 of 2 selected).

Your practice so far

Check an answer to see its rationale.

Teacher guidance and scoring