I am developing an intentionally simple probabilistic model of primes with the aim of modelling experimentally measured prime gaps.

Question: My simple model has the right shape, and broadly has the right magnitudes - my questions is, how can it be improved? Is there a flaw in my logic?

Note: I have been inspired by an answer to this question (but I didn't understand it totally): Distribution of prime gaps - is it an unsolved problem?

Step 1

The Prime Number Theorem (PNT) tell us that primes occur with a density of $1/\log(x)$ in the neighbourhood of $x$, and this is increasingly true for larger $x$. We can interpret this as a probability of $n$ being prime.

$$P(n) = \frac{1}{\log(n)}$$

The probability that a number is not prime is:

$$P'(n) = \left ( 1 - \frac{1}{\log(n)} \right )$$

Step 2

A prime gap of length 2 means we have a sequence (prime, not prime, prime). Similarly a prime gap of length 4 means a sequence (prime, not prime, not prime, not prime, prime). A prime gap of length $g$ at $n$ would require a sequence (prime, g-1 not primes, prime) and so a probability:

$$ P_{gap}(g) = P(n) \cdot P'(n+1)\cdot P'(n+1) \ldots P'(n+g-2) \cdot P'(n+g-1) \cdot P(n+g) $$

Step 3

For large $x$, we can approximate $\ln(x+g) \approx \ln(x)$, because most $g$ will be much smaller than $x$. This simplifies the probability of a prime gap to

$$ \begin{align} P_{gap}(g) &\approx \frac{1}{\log(n)} \cdot \left (1-\frac{1}{\log(n)} \right )^{g-1} \cdot \frac{1}{\log(n)} \\ \\ &= \left (1-\frac{1}{\log(n)} \right )^{g-1} \cdot \frac{1}{\log^2(n)} \end{align}$$

Step 4

Again, being approximate, the number of gaps of size $g$ in a number range of length $N$ is $N\cdot P_{gap}(g)$.

Taking logs we have:

$$ \ln\left( N\cdot P_{gap}(g) \right) = (g-1) \cdot \ln \left (1-\frac{1}{\ln(n)} \right ) + \ln ( \frac{1}{\ln^2(n)}) +\ln(N)) $$

This is a linear function of $g$ of the form $Ag+B$. with a negative gradient because $(1-\frac{1}{\ln(n)} )$ is less than 1, so its logarithm is less than 0.

The following compares this function with $n=500,000,000$ with experimentally determined counts of prime gaps in the range 1 to 500,000,000.

enter image description here

The simple model is linear, and has a negative gradient - this is good. The simple model has the right order of magnitude - good. But how can the discrepancy be improved.


I have intentionally avoided the refinements which adjust the simple model to take into account that even numbers are never prime. I don't feel it makes a difference over larger scales. Am I wrong?

I am aware that some model try to correct for the assumption that selecting a series of numbers, their probability of being prime is not independent. Would this make a difference? How would I do it?

I would appreciate replies suitable for an audience not trained to university level mathematics.

  • 1
    $\begingroup$ $(1)$ We can consider small prime factors like $2$ and refine the $1/ln(n)$ model, the "probability" for a large number to be prime is the only multiplied with a constant. For large enough numbers this gives a reasonable accurate conditional "probability" for a number to be prime given it has no small factors. $\endgroup$
    – Peter
    Apr 18, 2021 at 8:16
  • 1
    $\begingroup$ $(2)$ The $1/ln(n)$ model cannot prove, for example , the twin prime conjecture. It gives only a heuristic. In reality , a given number is prime or not. The probability arises if we pick up a random number of a large range of large numbers like $[10^{100},10^{101}]$ and ask whether the selected number will be prime. $\endgroup$
    – Peter
    Apr 18, 2021 at 8:19
  • $\begingroup$ @peter thanks for your comments. The first comment has a typo/missing word and I'd like to understand it properly. Could you complete it? "Is the only multiplied" $\endgroup$
    – Penelope
    Apr 18, 2021 at 16:31
  • $\begingroup$ I tried to exclude even numbers, thus doubling the probability of being prim to $2/\log(n)$ where $n$ is only odd. The prime gaps also take an adjustment now. The result is a $\ln\left( N\cdot P_{gap}(g) \right) = (\frac{g}{2}-1) \cdot \ln \left (1-\frac{2}{\ln(n)} \right ) + \ln ( \frac{2}{\ln^2(n)} )+ \ln N )$and the resulting graph now looks better but now overestimates the larger gaps desmos.com/calculator/mdgei1khbs $\endgroup$
    – Penelope
    Apr 18, 2021 at 18:03
  • $\begingroup$ It should be "is only multiplied with a constant". Sorry for the confusion ! $\endgroup$
    – Peter
    Apr 18, 2021 at 18:14

1 Answer 1


This is the best I can do.

Based on the random model for the primes, the predicted values follow the same idea as the twin prime constant, to improve the $(1-1/\log n)^k$ prediction.

The curve shows that it is clearly the right approach, though there seems to be a bias somewhere that we should be able to reduce by improving the model.

enter image description here

  • $\begingroup$ hi @reuns - thanks for this. I noticed in your previous comments you modelled a sequence as (prime)(not prime)(not prime) etc .. whereas I modelled (prime)( sequence of not primes)(prime) ... that is, I added a final prime in the probability calculation. Is there a strong reason to prefer one over the other? $\endgroup$
    – Penelope
    Apr 19, 2021 at 19:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .