The long-range electronic correlations in a uniform electron gas may be ded
uced from the random-phase approximation (RPA) of Bohm and Pines [Phys. Rev
. 92, 609 (1953)]. Here we generalize the RPA to nonuniform systems and use
it to derive many-electron Slater-Jastrow trial wave functions for quantum
Monte Carlo simulations. The RPA theory fixes the long-range behavior of t
he inhomogeneous two-body terms in the Jastrow factor and provides an accur
ate analytic expression for the one-body terms. It also explains the succes
s of Slater-Jastrow trial functions containing determinants of Hartree-Fock
or density-functional orbitals, even though these theories do not include
Jastrow factors. After adjusting the RPA Jastrow factor to incorporate the
known short-range behavior, we test it using variational Monte Carlo simula
tions. In the small inhomogeneous electron gas system we consider, the anal
ytic RPA-based Jastrow factor slightly outperforms the standard numerically
optimized form. The inhomogeneous RPA theory therefore enables us to reduc
e or even avoid the costly numerical optimization process.