Radius of gyration (source code)

= Radius of gyration
{title2=$R_g^2=\frac1{2N^2}\sum_{m,n}\langle|\mathbf R_m-\mathbf R_n|^2\rangle$}
{wiki}

For $N$ equally weighted positions, the squared <radius of gyration> is the average squared distance from the <center of mass>: $R_g^2=N^{-1}\sum_n\langle|\mathbf R_n-\mathbf R_{\rm cm}|^2\rangle$, where $\mathbf R_{\rm cm}=N^{-1}\sum_n\mathbf R_n$. Expanding pair differences gives $\sum_{m,n}|\mathbf R_m-\mathbf R_n|^2=2N\sum_n|\mathbf R_n-\mathbf R_{\rm cm}|^2$, and therefore
$$
R_g^2=\frac1{2N^2}\sum_{m,n}\langle|\mathbf R_m-\mathbf R_n|^2\rangle.
$$
For a <Gaussian chain> or <freely jointed chain> with these $N$ positions and mean squared link length $b^2$, each pair <variance> is $b^2|m-n|$. Summing separations yields $R_g^2=b^2(N^2-1)/(6N)\sim Nb^2/6$. Counting all endpoints of $N$ links instead gives $N+1$ positions and the corresponding finite-size formula.