Heuristics of counting twin primes I was reading on counting the number of twin primes and I found this heuristic explanation on the Hardy-Littlewood conjecture, which states that $$\pi_2(x)\sim 2\Pi_2 \frac{x}{\log^2(x)},$$ where $\pi_2$ denotes the number of twin primes smaller than $x\in[0,\infty)$ and $$\Pi_2=\prod_{p\geq 3}\left(1-\frac{1}{p}\right)^{-2}\frac{p-2}{p}.$$ The explanation given goes as follows:
The prime number theorem states that $\pi(x)\sim\frac{x}{\log(x)}$ where $\pi(x)$ denotes the number of primes smaller than $x\in[0,\infty)$. Then, we say that the probability that an integer $a\in[1,n]$ is $\frac{1}{\log(n)}$. Assuming that $a$ and $a+2$ being prime are independent events, the probability of both of them being prime is $\frac{1}{\log^2(n)}$. However, this is obviously not true since (for example) if $a$ is prime, $a+2$ is more likely to be prime, since it is not divisible by $2$. We refine this model as follows: given a "small" integer $w>0$ we say that the probabily of an integer $a\in[1,n]$ being prime is $0$ if some prime $p\leq w$ divides $a$ and
$$\prod_{p\leq w} \left(1-\frac{1}{p}\right)^{-1}\frac{1}{\log(n)}$$ otherwise.
Then, we count the number of twin primes smaller than $n$ using this model to get
$$2\prod_{p\leq w,\ p\neq 2}\left(1-\frac{1}{p}\right)^{-2}\frac{p-2}{p}\frac{n}{\log^2(n)}.$$
Letting $w\to\infty$ we get the result in the conjecture.
What I don't understand is the final counting part. According to my source, the $2$ appears because if $a$ is prime, $a+2$ is odd, and the factor $\frac{p-2}{p}$ appears because out of $p$ numbers, only $p-2$ can be the biggest of a twin prime because the ones congruent to $0$ or $2$ modulus $p$ cannot be. I understant this facts but I don't know how to apply them to calculate the estimated number of twin primes smaller than $n$. Any insight would be appreciated.
 A: For such heuristic considerations, it's often useful to think not in terms of the prime (or twin prime) counting function but in terms of the corresponding densities. For the connection between the prime number theorem and the “prime density”, see e.g. Wikipedia.
So think of $\frac1{\log x}$ as the density of primes at $x$ and of $\frac{2\Pi_2}{\log^2x}$ as the density of twin primes at $x$.
A first estimate of the twin prime density at $x$ might be $\frac1{\log^2 x}$. However, as you described, this assumes that the events of $x$ and $x+2$ being prime are independent, which they are clearly not. The idea is to correct the probability for each prime separately. Whereas under the independence assumption the probability of $x$ and $x+2$ not being divisible by $p$ would be $\left(1-\frac1p\right)^2$, it is in fact $1-\frac2p$, so we correct the estimate by the ratio $\left(1-\frac2p\right)\left(1-\frac1p\right)^{-2}$. We need to make an exception for $p=2$, since here the probability of being divisible by $2$ is not $1-\frac22=0$ but $\frac12$, whereas under the independence assumption it would be $\left(\frac12\right)^2$, so we start the product at $p=3$ and correct for the ratio $\frac12\left(\frac12\right)^{-2}=2$ separately.
We pretend that the density $\frac1{\log x}$ arises from multiplying the probabilities of the independent events of not being divisible by each prime and correct each of these probabilities by the appropriate ratio. Of course this can't really be true, since $\prod_p\left(1-\frac1p\right)$ diverges and we'd have to somehow truncate it somewhere around $\sqrt x$, since beyond that there are no new prime factors to be found; but since we're only interested in the asymptotic density and the correction factor
$$
\frac{1-\frac2p}{\left(1-\frac1p\right)^2}=\frac{1-\frac2p}{1-\frac2p+\frac1{p^2}}=\frac1{1+\frac1{p^2-2p}}=1+O\left(\frac1{p^2}\right)
$$
converges to $1$ rapidly enough to make the product of the correction factors converge, we can get away with ignoring this complication.
