smartyfy.mrindigi.com

Quantum Computing Master Course — 002. Bits, Probability, and Repeated Experiments

Lesson 002: Bits, Probability, and Repeated Experiments

Smartyfy Quantum Computing Master Course

Prerequisites and objectives

Read Lesson 001 first. You should be comfortable with fractions and decimals. This lesson teaches you to validate a probability distribution, combine independent events, calculate an expected count, and interpret a finite sequence of outcomes. These skills apply to classical random experiments and to the classical records produced by quantum measurements.

Outcomes and distributions

A bit has possible values zero and one. Before observing the outcome of an experiment, we might assign P(0) = 0.7 and P(1) = 0.3. The symbol P means probability. These numbers describe a model for the experiment, not a promise that every group of ten runs will contain exactly seven zeros.

A finite probability distribution must satisfy two conditions. Every probability is nonnegative, and the probabilities of all mutually exclusive, exhaustive outcomes add to one. Exhaustive means that the list includes every possible outcome. Mutually exclusive means that a single run cannot produce two different listed outcomes simultaneously.

For a binary outcome, knowing P(1) determines P(0): it equals 1 − P(1). Thus 0.7 and 0.3 form a valid distribution. The proposed pair 0.7 and 0.5 does not, because the total is 1.2. The pair 1.1 and −0.1 also fails: adding to one is necessary but does not excuse a negative probability. IBM’s treatment of classical information formalizes this as a probability vector.

Events, complements, and independence

An event can include several outcomes. Suppose two bits are recorded in the order first bit, second bit. The possible strings are 00, 01, 10, and 11. The event “exactly one one” contains 01 and 10. Because these strings are mutually exclusive, their probabilities add.

If two experiments are independent, learning the result of one does not change the probability model for the other. Under this assumption, joint probabilities multiply. For two independent repetitions with P(1) = 0.3, P(11) = 0.3 × 0.3 = 0.09. Similarly P(00) = 0.7 × 0.7 = 0.49, and P(01) = P(10) = 0.21. The four probabilities sum to one.

The probability of exactly one one is therefore 0.21 + 0.21 = 0.42. The probability of at least one one is 1 − P(00) = 0.51. Notice that “exactly one” and “at least one” are different events. Drawing a small outcome list before doing arithmetic prevents many mistakes.

Independence is an assumption to justify, not a default property of every collection of bits. A process that outputs either 00 or 11 with equal probabilities has individually fair bits, yet the second bit is fully determined after the first is known. Multiplying the marginal probabilities would incorrectly assign probability one quarter to 01.

A two-level probability tree starts with first-run zero or one, with probabilities 0.7 and 0.3. Each second run repeats those probabilities independently. The joint outcomes 00, 01, 10, 11 have probabilities 0.49, 0.21, 0.21, 0.09. Highlighted mutually exclusive outcomes 01 and 10 sum to 0.42 for exactly one one.
For independent runs, multiply probabilities along each path. Then add the disjoint paths 01 and 10 to get the probability of exactly one one. The independence assumption is essential. Open full-size diagram

Worked example: counts and uncertainty

Imagine 200 independent, identically prepared runs with probability 0.3 of outcome one. “Identically prepared” means that the same probability model applies to every run. The expected number of ones is 200 × 0.3 = 60. An expectation is a long-run average over repeated batches, not a required result for one batch.

If a particular batch contains 66 ones, its observed frequency is 66/200 = 0.33. The difference from the model probability is 0.03. That discrepancy alone does not prove an error: finite random samples fluctuate. Conversely, obtaining exactly 60 ones would not prove that the apparatus follows the proposed model in every respect.

For independent binary trials, the standard deviation of the count is the square root of Np(1 − p). Here it is the square root of 42, approximately 6.48. The standard deviation of the frequency is approximately 6.48/200 = 0.0324. This gives a scale for ordinary sampling variation. It is not a guaranteed error bound or a complete statistical test.

The frequency’s standard-deviation formula also shows a useful resource tradeoff. Multiplying the number of independent runs by four halves this sampling scale. Collecting more runs does not automatically remove a systematic bias, such as a detector that consistently mislabels outcomes. Random uncertainty and systematic error need different diagnoses.

A local sampling experiment

The following Python example uses only the standard library. The seed makes the pseudorandom experiment reproducible in this environment. This is a classical sampler for a binary distribution. It contains no qubit state and is not a quantum-hardware experiment.

from random import Random
rng = Random(2026)
p_one = 0.3
shots = 1000
ones = sum(rng.random() < p_one for _ in range(shots))
print("shots:", shots)
print("ones:", ones)
print("frequency:", ones / shots)
assert 0 <= ones <= shots
assert abs((ones / shots) + ((shots - ones) / shots) - 1) < 1e-12

The comparison with 0.3 generates a one whenever the sampled number falls in the lower thirty percent of the unit interval. The Boolean results count as one or zero when summed. The assertions check basic accounting, not that the empirical frequency must equal the model probability. Try changing the seed and the shot count separately, recording what stays fixed and what changes.

Four exercises

  1. Decide whether each pair is a valid binary distribution: (0.2, 0.8), (−0.2, 1.2), and (0.4, 0.4). Explain each decision.
  2. Two independent runs each have P(1) = 0.4. Calculate P(00), P(11), and the probability of exactly one one.
  3. A batch of 500 runs produces 185 ones. Find the observed frequency and the expected number under a model with P(1) = 0.4.
  4. A machine outputs 00 with probability 0.6 and 11 with probability 0.4. Are its two bits independent? Give a numerical check.

Exercise solutions

  1. The first pair is valid because both entries are nonnegative and total one. The second has a negative entry. The third totals only 0.8 and leaves probability unaccounted for.
  2. P(00) = 0.6² = 0.36. P(11) = 0.4² = 0.16. Exactly one one has probability 2 × 0.6 × 0.4 = 0.48.
  3. The frequency is 185/500 = 0.37. The expected count is 500 × 0.4 = 200. A difference of fifteen does not, by itself, identify its cause.
  4. They are dependent. Each marginal assigns probability 0.4 to one, but P(11) = 0.4 differs from 0.4 × 0.4 = 0.16.

Five multiple-choice checks

  1. Which distribution is valid? A. (0.5, 0.7). B. (1.2, −0.2). C. (0.15, 0.85). D. (0, 0).

    Answer: C. It meets both nonnegativity and unit-total requirements; each other choice violates at least one.

  2. For independent events with probabilities 0.2 and 0.5, their joint probability is: A. 0.1. B. 0.7. C. 0.3. D. 2.5.

    Answer: A. Independence permits multiplication, giving 0.2 × 0.5.

  3. An expected count of 40 means: A. Every batch contains 40. B. Forty is the average across the model’s repeated batches. C. Other counts are errors. D. The first 40 results must succeed.

    Answer: B. Expectation summarizes a distribution of counts rather than specifying one outcome.

  4. Which change halves the standard deviation of a frequency under independent identical trials? A. Twice as many runs. B. Four times as many runs. C. A new label. D. Sorting the results.

    Answer: B. The sampling scale decreases as one divided by the square root of the run count.

  5. Two individually fair bits must be: A. Independent. B. Equal. C. Different. D. None of these necessarily.

    Answer: D. Marginal probabilities alone do not determine their joint dependence.

Pitfalls and summary

Do not confuse a model probability with an observed frequency, add probabilities of overlapping events without adjustment, or multiply probabilities without checking independence. Keep the preparation procedure and outcome labels explicit. Next, vectors give us a compact language for storing ordered information and eventually quantum amplitudes.

Primary sources and further study

These sources support the definitions and context. The numerical examples, exercises, and explanations here were prepared for this lesson. Research papers are optional advanced reading.