Derivation of Wikipedia's path tracing diffuse BRDF Wikipedia's path tracing algorithm has the following line for the diffuse BRDF:

Color BRDF = 2 * m.reflectance * cos_theta;


I'm a little confused as I've been reading that Lambertian surface BRDF is $\frac{\rho}{\pi}$ where $\rho$ is the reflectivity (albedo?) of the surface. Where does the $2$ come from?
When you perform regular Monte Carlo integration over a hemisphere using $N$ samples, each sample represents $\frac{2\pi}{N}$ steradians. So the Monte Carlo integration for Lambertian BRDF is:

$$\frac{2\pi}{N}\sum_{i=1}^N\frac{\rho}{\pi}L_i*Cos\theta_i$$

For path tracing, you only take one sample per path segment, so because $N$=1, the above sum becomes:

$$2\pi\frac{\rho}{\pi}L*Cos\theta = 2\rho L*Cos\theta$$