Choose a bag, then draw: total probability
Choose a bag, then draw: total probability
First choose bag I with probability p, otherwise bag II. Then draw one object uniformly from that bag. Each bag has the target and other counts shown below. Find the overall probability of drawing a target.
- 101 bytes
- COMP mode
Worked examples
Example 1
Original exercise 1. First choose bag I with probability p, otherwise bag II. Then draw one object uniformly from that bag. Each bag has the target and other counts shown below. Find the overall probability of drawing a target. Data: A=p=P(I), probability = 0.5; B=u₁, I target count = 7; C=v₁, I count − u₁ = 3; D=u₂, II target count = 3; X=v₂, II count − u₂ = 2.
- (a)Calculate all requested quantities in the stated order. Output order: probability.
Answer
Standard solution (without a calculator)
- Build the mathematical model and substitute the data. P(I)=p; P(II)=1−p.
- Written solution: P(H|I)=7/(7+3)=7/10; P(H|II)=3/(3+2)=3/5.
- P(H∩I)=(1/2)(7/10)=7/20; P(H∩II)=(1/2)(3/5)=3/10.
- P(H)=(7/20)+(3/10)=13/20.
- Retain exact fractions in written work; round only the final answer.
Example 2
Original exercise 2. First choose bag I with probability p, otherwise bag II. Then draw one object uniformly from that bag. Each bag has the target and other counts shown below. Find the overall probability of drawing a target. Data: A=p=P(I), probability = 0.75; B=u₁, I target count = 2; C=v₁, I count − u₁ = 4; D=u₂, II target count = 3; X=v₂, II count − u₂ = 9.
- (a)Calculate all requested quantities in the stated order. Output order: probability.
Answer
Standard solution (without a calculator)
- Build the mathematical model and substitute the data. P(I)=p; P(II)=1−p.
- Written solution: P(H|I)=2/(2+4)=1/3; P(H|II)=3/(3+9)=1/4.
- P(H∩I)=(3/4)(1/3)=1/4; P(H∩II)=(1/4)(1/4)=1/16.
- P(H)=(1/4)+(1/16)=5/16.
- Retain exact fractions in written work; round only the final answer.
Example 3
Original exercise 3. First choose bag I with probability p, otherwise bag II. Then draw one object uniformly from that bag. Each bag has the target and other counts shown below. Find the overall probability of drawing a target. Data: A=p=P(I), probability = 0.25; B=u₁, I target count = 0; C=v₁, I count − u₁ = 6; D=u₂, II target count = 2; X=v₂, II count − u₂ = 6.
- (a)Calculate all requested quantities in the stated order. Output order: probability.
Answer
Standard solution (without a calculator)
- Build the mathematical model and substitute the data. P(I)=p; P(II)=1−p.
- Written solution: P(H|I)=0/(0+6)=0; P(H|II)=2/(2+6)=1/4.
- P(H∩I)=(1/4)(0)=0; P(H∩II)=(3/4)(1/4)=3/16.
- P(H)=(0)+(3/16)=3/16.
- Retain exact fractions in written work; round only the final answer.
When to use it
First choose bag I with probability p, otherwise bag II. Then draw one object uniformly from that bag. Each bag has the target and other counts shown below. Find the overall probability of drawing a target.
Input order
- A=p=P(I), probability
- B=u₁, I target count
- C=v₁, I count − u₁
- D=u₂, II target count
- X=v₂, II count − u₂
- Every displayed input is required unless a blank is explicitly specified. Empty EXE keeps a stored value, whereas typing 0 replaces it with zero. The listed domain conditions must be checked even when the program does not test all of them.
Output order
- probability
- Record the value and press EXE.
- The program has ended. Press AC to leave; EXE runs it again.
Conditions and limitations
- 0≤p≤1; u₁,v₁,u₂,v₂∈ℤ (≥0); u₁+v₁>0; u₂+v₂>0.
- vⱼ=Nⱼ−uⱼ.
- −1: p∉[0,1] / uⱼ<0 / vⱼ<0 / uⱼ+vⱼ=0.
- Every displayed input is required unless a blank is explicitly specified. Empty EXE keeps a stored value, whereas typing 0 replaces it with zero. The listed domain conditions must be checked even when the program does not test all of them.
- Use consistent units throughout.
- Finite precision can lose small differences between large numbers or probabilities extremely near 0 or 1. An error marker is never a valid answer.
Checking access…