I was wondering about the variance for Monte Carlo. The book (Advanced Global Illumination 2ed, p.60) writes the equation as follows:
$\sigma^2 = \frac{1}{N} \int(\frac{f(x)}{p(x)} - I)^2p(x)dx$
$\space\space\space\space=\color{red}{\frac{1}{N} \int(\frac{f(x)}{p(x)})^2p(x)dx -I^2}$
$\space\space\space\space=\frac{1}{N} \int\frac{f(x)^2}{p(x)}dx -I^2$
However, the equation appears incorrect. I think the red area is wrong and the equation should be changed as follows:
$\sigma^2 = \frac{1}{N} \int(\frac{f(x)}{p(x)} - I)^2p(x)dx$
$\space\space\space\space=\color{red}{\frac{1}{N} \int((\frac{f(x)}{p(x)})^2 -2\frac{f(x)}{p(x)}I + I^2)p(x)dx}$
$\space\space\space\space=\frac{1}{N} \int\frac{f(x)^2}{p(x)} - 2f(x)I + I^2p(x)dx$
$\space\space\space\space=\frac{1}{N} \int\frac{f(x)^2}{p(x)} - 2f(x)I dx \space + \frac{1}{N}I^2$
$\space\space\space\space=\frac{1}{N} \int\frac{f(x)^2}{p(x)} dx - \frac{2}{N}I^2 \space + \frac{1}{N}I^2$
$\space\space\space\space=\frac{1}{N} \int\frac{f(x)^2}{p(x)} dx - \frac{1}{N}I^2$
Is it right?