Journal entry / Science & Materials

What Does Randomness Look Like? A Lottery, a Quantum Computer, and Knowing When to Stop

It started with a question that sounds a little ridiculous: could a quantum computer tell us anything interesting about lottery numbers? And, what could I do with 10 minutes worth of compute time on a quantum computer?

Not “predict the next jackpot.” That would require information that, under a fair lottery, simply is not there. The question that bothered me was more basic: what does randomness actually look like, and is the mechanism behind the randomness discernible to a degree from the randomness?

If you look at lottery drawings for long enough, the numbers often seem strangely well distributed. You see a low number, something in the middle, something high. Five numbers packed into one narrow part of the range feel unusual. A sequence such as 1, 2, 3, 4, 5 feels almost impossible—even though any one valid five-number combination has exactly the same probability as any other.

That tension between what randomness is mathematically and what randomness looks like to a human became the starting point for Q-RAND: Quantum-Assisted Residual Anomaly and Nonrandomness Detection. Q-Lotto was the less dignified repository codename.

Concept Note: Random Does Not Mean “Patternless”

For a fair drawing, every particular valid combination has the same probability. But categories of combinations do not contain the same number of possibilities. There is only one exact set {1,2,3,4,5}, while enormous numbers of five-number sets look broadly spread across the available range.

If five white balls are chosen from 70, there are C(70,5) = 12,103,014 possible five-number sets. A particular set therefore has probability 1 / 12,103,014. “Spread-out sets,” however, describe a huge collection of those individual possibilities. Random drawings can therefore have a recognizable overall shape without making any particular combination more likely.

This distinction, individual outcomes versus the distribution of features of outcomes, is central to statistical randomness testing. Established suites examine properties such as frequency, runs, correlation, and spectral behavior rather than trying to declare a particular sequence “random-looking.” See the NIST guide to statistical tests.

The lottery was the laboratory, not the prediction target

Mega Millions gave us an unusually convenient experimental system. It is a long-running physical process with public observations and clearly defined rules. We can reproduce the expected process mathematically: select the required number of balls without replacement, repeat, and compare the resulting universe of simulated drawings with what the real system produced.

The important idea was not to ask which numbers were “hot.” It was to ask whether the real drawings contained structure that the known random process did not already explain.

That distinction matters. Random selections have structure. If you choose five numbers from a large range, most selections will look reasonably spread out simply because there are far more ways to make a spread-out set than to cram all five values into a tiny interval. A pattern that looks meaningful may therefore be exactly what randomness predicts.

First rule: make it difficult to fool ourselves

Before analyzing the outcomes, I froze a protocol. That decision became more important than anything quantum I eventually did.

I defined five historical Mega Millions rule regimes, fourteen families of measurable features, deterministic random seeds, statistical corrections for testing many possible patterns, and chronological discovery and holdout partitions. Seventy percent of each historical regime could be used for discovery. The remaining thirty percent was sealed for possible confirmation.

I also decided in advance what evidence would be strong enough to justify moving a discovered residual into the quantum stage. If nothing crossed that line, there would be no historical quantum model.

That sounds bureaucratic until an interesting number appears.

Method Note: Why Freeze the Rules?

Suppose we inspect enough features of a random dataset. Even when nothing unusual is happening, eventually one feature will look surprisingly extreme. This is the multiple-comparisons problem: the more questions we ask of the same data, the more opportunities we create for chance to imitate discovery.

Predeclaring the tests, significance rules, and stopping gates separates “this surprised us” from “this met the standard we chose before we knew the answer.” A chronological holdout adds another safeguard: discovery data can suggest a finding, while untouched later data can test whether it survives.

The same logic applies to engineering gates. The later 500-layer circuit limit was not a law of physics. It was a boundary chosen before seeing the compiled result. Once the answer was 511, changing 500 to 520 would have changed the experiment because I had seen the answer.

Then 0.0463 appeared

I assembled and reconciled 2,540 official lottery drawings through September 15, 2026, correcting five source discrepancies and leaving none unresolved. I built exact combinatorial checks and large deterministic Monte Carlo reference populations, then validated the detector using synthetic histories in which routines had secretly planted known biases.

The detector’s familywise false-positive rate came out at 4.977% against the declared 5% target. It was very good at finding some planted structures, at a 5% signal strength it detected a planted pair relationship about 90.7% of the time and a planted triple interaction about 99.0% of the time. It was much weaker at several deliberately subtle mechanisms. I kept those weaknesses in the result rather than tuning them away.

Concept Note: Anomaly Detection Is Not One Algorithm

There are many ways to search for unusual structure. Classical approaches include distribution and runs tests, autocorrelation and spectral analysis, density and distance methods, Isolation Forest, Local Outlier Factor, One-Class SVMs, change-point detection, and many others. Different methods are sensitive to different departures.

Q-RAND was not an attempt to replace that field with a quantum computer. Its experimental structure was: define the expected generator → simulate its null behavior → measure residual structure → plant known anomalies to measure detector power → only then consider a quantum representation of a qualifying residual.

That “plant something and see whether you can recover it” step matters. A detector that finds nothing is only informative if we know what kinds of things it was capable of finding. For an approachable overview, see the scikit-learn novelty and outlier detection guide.

Then I opened the permitted historical discovery data.

One feature family, spectral structure, produced an unadjusted p-value of 0.0463.

If I had simply used the familiar “p < 0.05” shortcut, that number would have been wonderfully tempting. But I had tested fourteen families of possible structure. Our preregistered correction existed precisely because, if you look in enough places, something eventually looks unusual by chance.

After the correction I had committed to before seeing the result, the global p-value was 0.3925.

No historical anomaly qualified. I did not promote the spectral result, did not try a slightly different statistic, and did not open the sealed holdout data. The historical experiment stopped there.

That was my first useful negative result.

So why continue toward a quantum computer?

Because I had already shown that the method could detect known synthetic structure. Instead of pretending that Mega Millions had given an anomaly, I created one and asked a cleaner methodological question:

If we know that a residual structure exists, can we represent and sample its probability landscape with a quantum formulation?

Reducing the problem to a controlled 5-of-12 system, there are exactly 792 valid five-element states. I planted a relationship between two elements, numbered 4 and 11, and retained a zero-signal negative control. Because I created the synthetic mechanism, I knew the correct answer.

Exhaustively checking all 4,096 possible binary states, I verified the mathematical mappings before doing anything with hardware.

Quantum Note: What Is a Qubit, and Why Use One Here?

A classical bit is measured as 0 or 1. A qubit is described by quantum amplitudes for the basis states |0⟩ and |1⟩. Before measurement its state can be written as |ψ⟩ = α|0⟩ + β|1⟩, with |α|² + |β|² = 1. Multiple qubits form a joint state whose amplitudes can interfere as quantum gates transform the system.

This does not mean a quantum computer simply “tries every answer at once and reads them all.” Measurement still produces ordinary outcomes. The useful trick is to design operations so interference reshapes the amplitudes: states representing better solutions or a desired probability landscape can become more likely when measured.

For our tiny 12-variable experiment, classical computation could solve and simulate the entire problem—we enumerated all 4,096 binary states. That was a feature: it gave us exact ground truth against which to judge the quantum formulation. The question was whether the residual landscape could be represented faithfully in a constrained quantum process, not whether twelve variables required quantum speedup. For background, see IBM’s introduction to qubits.

The first quantum formulation failed

The first QAOA design used a conventional transverse-field X mixer. It was mathematically reasonable, but the problem has a strict constraint: exactly five of the twelve variables must be selected.

The mixer did not respect that constraint. At shallow circuit depths, probability continually leaked into invalid states. The best configuration put only about 75–77% of its probability on valid states, nowhere near the 99% admission gate we had set beforehand.

Again, I stopped.

Verifying the implementation independently, it showed an analytic statevector calculation and Qiskit agreed to approximately 3.5 × 10⁻¹⁷. The failure was not a bit-ordering mistake or a broken conversion, it was saying something about the architecture.

The second formulation fixed the right problem

For the next, explicitly separate exploratory experiment, I stopped asking the quantum circuit to wander through invalid states and then punish itself for doing so.

Instead, I began in a uniform state containing exactly five selected variables and used an XY exchange mixer that preserves that count. In simple terms: if only five-item answers are legal, build a quantum process that only explores five-item answers.

The change was dramatic. The negative control achieved fidelity 1.000000. The positive control achieved 0.999128. Ideal leakage outside the valid 5-of-12 space fell essentially to zero.

Logically, the quantum experiment now worked.

Then physics and engineering got a vote

A correct logical circuit is not automatically a practical physical circuit. Real quantum processors have limited connectivity, noisy two-qubit operations, and finite useful circuit depth. State preparation and routing matter.

Quantum Note: Why Not Just Simulate It?

At this scale, one probably should, and I did. Exact classical simulation lets us verify the target distribution, inspect every state, and catch implementation mistakes before touching scarce hardware.

But a generic statevector for n qubits contains 2n complex amplitudes. Twelve qubits means 4,096 amplitudes; 30 means more than a billion. Clever classical methods avoid that cost for many special problems, so exponential statevector size by itself is not a claim of quantum advantage. It does explain why exact simulation stops being a universal safety net as systems grow.

The physical QPU stage asks a different question: can this probability-shaping process actually be implemented and sampled on quantum hardware, and how does its distribution depart from exact and noisy-simulation references? In Q-RAND Experiment 1, the circuit had to earn that hardware stage first.

This froze at another gate: the complete circuit had to compile to a two-qubit depth of no more than 500 on an accessible IBM Quantum backend before I would spend hardware time.

Screening the available systems, none passed for both controls. I did allow one separately preregistered synthesis experiment using a clean work qubit and exact relative-phase-Toffoli compute/uncompute to reduce preparation cost. The logical result remained exact.

On IBM Fez, the resulting depths were 511 for the negative control and 515 for the positive control.

Engineering Note: What Does “Circuit Depth” Mean?

A quantum circuit is a sequence of gates, but gates acting on different qubits can sometimes run in parallel. Circuit depth counts the sequential layers that remain after that parallelism is considered. Two-qubit gates matter especially on current hardware because they are generally more error-prone and limited connectivity can require additional routing operations.

So a two-qubit depth of 511 does not mean “511 calculations.” It means the compiled circuit contains roughly 511 sequential layers of relevant two-qubit work along its critical path under our metric. More depth generally means more time and more opportunity for noise to damage the state.

Our limit of 500 was an experimental admission criterion, not a universal IBM limit. Reaching 511/515 was painfully close—but the value of a predeclared gate is precisely that “painfully close” does not redefine it.

Eleven layers.

It is difficult to describe how persuasive the phrase “close enough” becomes at that point.

But 511 is not 500.

I chose the threshold before seeing the result. Raising it afterward because the circuit nearly passed would turn an experimental decision into a negotiation with the data. So I froze the result here, submitted no QPU job, and used none of the quantum-computing allocation that I had originally set aside.

What did I actually learn?

I was not learning how to predict the lottery. That was never a scientifically credible objective. The goal was something more reusable.

A process can look patterned while behaving exactly as its random model predicts. A detector can be calibrated not only by asking whether it finds anomalies, but by planting known anomalies and measuring what it can and cannot detect. A statistically interesting residual is not automatically significant once all the places were searched are counted. A quantum formulation can fail for architectural reasons even when its mathematics looks sensible. A constraint can sometimes be handled more cleanly by constructing the state space correctly rather than adding penalties. And a logically successful quantum algorithm can still be impractical on the physical hardware available to you.

Perhaps most importantly, a negative result can tell you exactly where the next useful question begins.

The larger idea behind Q-RAND

The lottery turned out to be a convenient test organism for a much broader idea.

Every stream of observed numbers comes through some generating and measurement system: sensors, financial transactions, network telemetry, radio observations, manufacturing equipment, physical random processes, and countless others. If we have a reasonable model for what that system should produce, we can ask what structure remains after the expected behavior is accounted for.

That residual structure may tell us more than “something is odd.” In some systems it may contain information about the hidden mechanism that produced the observations: coupling, drift, periodic interference, memory, saturation, quantization, or some other property of the generator or measurement chain.

That is where Q-RAND gets more interesting to me. The lottery was simply a public, understandable place to begin asking the question.

And the quantum computer?

It never ran, but in the interests of only have 10 minutes of compute time available, I am surprisingly happy about that.

The purpose of access to a quantum processor is not to make sure every experiment eventually contains a screenshot from one. The purpose is to use the hardware when the experiment has earned the hardware.

This one got close. It also gave enough information to design the next experiment better: hardware feasibility can become an upstream design constraint, the hidden-generator problem can be made explicit, and the quantum stage can be sized from the beginning for the machines we can actually reach.

The ten minutes are still waiting, and so am I!

Filed under / Science & Materials · Software Development

Leave a Reply