Skip to content

AI & Automation

Statistical Deception: Predicting Lottery Numbers with AI

A neural network, 70 years of draw data, hundreds of lines of code. And in the end the AI is exactly as accurate as a chicken pecking at numbers. With an interactive simulator to try it yourself.

Jonas Höttler6 min read

Number games: when statistics become an illusion.

While googling, I kept finding posts about what you can supposedly predict with simple AI models — try it yourself, it's surprisingly entertaining. Lottery numbers, sporting events, even share prices (I may have prepared something on that too 😉). There seem to be a whole range of prediction "methods" people believe in, hoping to improve their chances.

So are more and more people winning the lottery now because they use these tools? Probably not. That's exactly what we'll look at here — and you can reproduce it yourself further down.

Up front: This article is for anyone interested in data analysis, AI and statistics. There are no tips or recommendations for gambling. The point is to understand — how these tests work and what they do (and don't) deliver.

Why we believe in our chances

Before we calculate anything, it's worth looking at the psychology. The German lottery started as "6 from 49": 13,983,816 possible combinations, so odds of 1:13,983,816 for six correct. Since the super number was added, the jackpot needs it too, and the odds dropped to 1:139,838,160 (Sachsenlotto, 2025). That's the curious effect: the win becomes less likely — and precisely because of that more attractive, because it's won less often and the jackpot grows.

Several psychological effects keep us believing we can improve our odds anyway:

EffectWhat happensSource
Jackpot effectBigger jackpots attract more players — even as the odds fall.Rockloff & Hing, 2013
Neglecting probability1:14M and 1:140M both just feel "very unlikely."Rogers, 1998
Availability heuristicWinners are everywhere in the media; the millions of losers are invisible.Griffiths & Wood, 2001
The "what if" fantasyThe pull is the daydream of winning, not the real expectation of it.Binde, 2013
Illusion of control"My system" gives a false sense of control over chance.Chodzyńska & Polak, 2023
The super-number paradox
6 from 49
1 : 13,983,816
→
+ super number
1 : 139,838,160
Ten times less likely — and yet more tempting. The rarer win grows the jackpot, and the huge jackpot drowns out any sober assessment of probability.

And it's important to know: the numbers are drawn independently. There is no link between this week's draw and last week's. This is exactly where the "methods" come in — "hot and cold numbers," number logic, wheeling systems, or neural networks: CNN, RNN, LSTM. We'll use an LSTM below.

In short: what is an LSTM?

LSTMs (Long Short-Term Memory) are special neural networks with a memory function. They store important information from the past and forget the unimportant — controlled by three "gates" (input, forget, output). They're particularly good at tasks with a temporal relationship: speech recognition, text generation, translation, time-series prediction, music composition.

Sounds like the perfect tool to "predict" a sequence of numbers over time. Here's an example using TensorFlow, Keras and scikit-learn:

import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, BatchNormalization
from tensorflow.keras.optimizers import Adam
from sklearn.model_selection import train_test_split


def prepare_data(df):
    """Prepares the data for the model"""
    draws = df[df['Typ'] == 'Normal'].groupby('Datum')['Zahl'].agg(list)
    features, labels = [], []
    for nums in draws:
        s = sorted(nums)
        # Statistical patterns that supposedly hint at future draws
        features.append([
            np.mean(s), np.std(s), np.median(s),
            max(s) - min(s),
            len([x for x in s if x % 2 == 0]),   # even numbers
            len([x for x in s if x <= 25]),       # numbers <= 25
            np.sum(s),
            np.prod(np.diff(s)),
        ])
        label = np.zeros(49)                       # one-hot over all 49 numbers
        for num in s:
            label[int(num) - 1] = 1
        labels.append(label)
    return np.array(features), np.array(labels)


def create_model():
    """Neural network for lottery prediction"""
    model = Sequential([
        Dense(256, activation='relu', input_shape=(8,)),
        BatchNormalization(), Dropout(0.3),
        Dense(512, activation='relu'),
        BatchNormalization(), Dropout(0.3),
        Dense(256, activation='relu'),
        BatchNormalization(), Dropout(0.3),
        Dense(49, activation='sigmoid'),           # 49 probabilities 0..1
    ])
    model.compile(optimizer=Adam(learning_rate=0.001),
                  loss='binary_crossentropy', metrics=['accuracy'])
    return model


def select_combination(predictions, num_combinations=5):
    """Picks the best combinations based on the predicted probabilities"""
    combos = []
    for _ in range(num_combinations):
        probs, selected = predictions.copy(), []
        for _ in range(6):
            probs = probs / np.sum(probs)
            idx = np.random.choice(49, p=probs)
            selected.append(idx + 1)
            probs[idx] = 0                          # don't pick the same number twice
        combos.append(sorted(selected))
    return combos

Train for 100 epochs on the historical draws, then ask for five suggested combinations. For the next draw, mine looked like this:

[1, 2, 3, 10, 13, 35]   avg 10.67   sum 64    historical matches: 6
[1, 2, 3,  8, 33, 36]   avg 13.83   sum 83    historical matches: 1
[1, 2, 14, 32, 34, 35]  avg 19.67   sum 118   historical matches: 3
[1, 2, 3, 11, 30, 35]   avg 13.67   sum 82    historical matches: 7
[1, 2, 5,  8, 33, 34]   avg 13.83   sum 83    historical matches: 4

It looks impressive. Tidy, "data-driven," with metrics. But does it do anything? Before I tell you — try it yourself.

Try it: AI vs. random

Below are two small modules. In the first you play a draw — a quick-pick ticket against the official draw. Click as often as you like and watch how rarely you even get three right. In the second you run the five AI tickets from this article against pure chance over many draws. Slide the count up and see where both end up.

INTERACTIVE · 01

Play a draw

One quick-pick ticket against the official draw. Click as often as you like — the jackpot won’t come.

Hit “Run a draw”.

INTERACTIVE · 02

AI vs. Random — reproduce it yourself

Run the article’s AI tickets against pure chance over many draws. Slide the count up.

Simulated draws2,000

Did you run it? Then you've already seen the point: both strategies settle at around 0.73 matches per ticket. That's not a quirk of the code — it's mathematics. The expected number of matches for any ticket is always 6 × 6/49 ≈ 0.735, no matter which six numbers you pick. No model on earth shifts that number.

The stress test with real data

I did exactly that with the real historical draws too: the five AI tickets against one thousand randomly generated tickets, across the entire lottery history. Normalized per ticket, for a fair comparison:

MatchesAI strategyRandom
3 correct79.6086.26
4 correct4.204.90
5 correct0.000.09
6 correct0.000.00
Avg. matches per ticket0.73590.7352
The verdict
Random even landed a five — the AI didn't get a single five or six. The difference in the average: 0.0007.
It's fair to say: a chicken pecking at six numbers between 1 and 49 twice a week is just as reliable a predictor as a fairly complex mathematical model.

What this really tells us

Let's step back. We used a special model, wrote many lines of code, downloaded 70 years of draw data — and in the end gained absolutely nothing. Our odds are exactly where they were; with pure chance they even looked a touch better (that can flip from draw to draw).

But it's far easier to build a system that advertises "the best mathematical models," "the strongest technology" and "the biggest winnings" than one that advertises the actual results. Winners get heavily publicized, dubious providers sell the matching feeling of winning "soon." At the end of the day, the statistical chance of winning is no better than drawing blind.

Now the more abstract level: in how many areas of life do we do things that may achieve nothing — but give us a sense of security? How often do we claim to have found a solution when it's pure marketing? My (incomplete, subjective) list:

  • Financial markets and trading strategies
  • Diets and health trends
  • Anti-aging products
  • Productivity apps and tools
  • Insurance for highly unlikely events
  • The coaching and self-help industry
  • Talismans and lucky charms
  • Sports supplements
  • "Data-driven" marketing

The lottery numbers are just the most honest example, because the result is so cleanly measurable here. For the others, measurement is harder — but the illusion of control is the same.

Sources

  • Binde, P. (2013). Why people gamble: A model with five motivational dimensions. International Gambling Studies, 13(1), 81–97.
  • Chodzyńska, K., & Polak, M. (2023). Information about objective probability of a lottery and the illusion of control. Polish Psychological Bulletin.
  • Griffiths, M., & Wood, R. (2001). The psychology of lottery gambling. International Gambling Studies, 1(1), 27–45.
  • Rockloff, M. J., & Hing, N. (2013). The Impact of Jackpots on EGM Gambling Behavior: A Review. Journal of Gambling Studies, 29(4), 775–790.
  • Rogers, P. (1998). The Cognitive Psychology of Lottery Gambling: A Theoretical Review. Journal of Gambling Studies, 14(2), 111–134.
  • Sachsenlotto. (2025). Winning probabilities Lotto 6aus49.

This article is purely for education and for understanding statistical tests. It is not gambling or investment advice.

Related Articles

Jonas Höttler builds software for mid-sized companies with Balane.