  We present a theory for the estimation of a scalar or a vector magnetic field
by its influence on an ensemble of trapped spin polarized atoms. The atoms
interact off-resonantly with a continuous laser field, and the measurement of
the polarization rotation of the probe light, induced by the dispersive
atom-light coupling, leads to spin-squeezing of the atomic sample which enables
an estimate of the magnetic field which is more precise than that expected from
standard counting statistics. For polarized light and polarized atoms, a
description of the non-classical components of the collective spin angular
momentum for the atoms and the collective Stokes vectors of the light-field in
terms of effective gaussian position and momentum variables is practically
exact. The gaussian formalism describes the dynamics of the system very
effectively and accounts explicitly for the back-action on the atoms due to
measurement and for the estimate of the magnetic field. Multi-component
magnetic fields are estimated by the measurement of suitably chosen atomic
observables and precision and efficiency is gained by dividing the atomic gas
in two or more samples which are entangled by the dispersive atom-light
interaction.
