  (Modified) We measure the distribution of carbon in the intergalactic medium
as a function of redshift z and overdensity delta. Using a hydrodynamical
simulation to link the H I absorption to the density and temperature of the
absorbing gas, and a model for the UV background radiation, we convert ratios
of C IV to H I pixel optical depths into carbon abundances. A careful analysis
of 19 high-quality quasar absorption spectra reveals that the carbon abundance
is spatially highly inhomogeneous and is well-described by a lognormal
distribution for fixed delta and z. Using data in the range log(delta) = -0.5 -
1.8 and z = 1.8 - 4.1, and a renormalized version of the Haardt & Madau (2001)
model for the UV background radiation from galaxies and quasars, we measure a
median metallicity of [C/H] = -3.47 + 0.08(z-3) + 0.65[log(delta)-0.5] and a
lognormal scatter of sigma([C/H]) = 0.76 + 0.02(z-3) - 0.23[log(delta)-0.5].
Thus, we find significant trends with overdensity, but no evidence for
evolution. These measurements imply that gas in this density range accounts for
a cosmic carbon abundance of [C/H] = -2.80 +/- 0.13 (Omega_C = 2e-7), with no
evidence for evolution. The dominant source of systematic error is the spectral
shape of the UV background, with harder spectra yielding higher carbon
abundances. While the systematic errors due to uncertainties in the spectral
hardness may exceed the quoted statistical errors for delta < 10, we stress
that UV backgrounds that differ significantly from our fiducial model give
unphysical results. The measured lognormal scatter is strictly independent of
the spectral shape, provided the background radiation is uniform. We also
present measurements of the C III/C IV ratio (which rule out collisional
ionization) and of the evolution of the effective Lyman-alpha optical depth.
