  We extend to higher dimensions some of the valuative analysis of
singularities of plurisubharmonic (psh) functions developed by the last two
authors. Following Kontsevich and Soibelman we describe the geometry of the
space V of all normalized valuations on C[x_1,...,x_n] centered at the origin.
It is a union of simplices naturally endowed with an affine structure. Using
relative positivity properties of divisors living on modifications of C^n above
the origin, we define formal psh functions on V, designed to be analogues of
the usual psh functions. For bounded formal psh functions on V, we define a
mixed Monge-Ampere operator which reflects the intersection theory of divisors
above the origin of C^n. This operator associates to any (n-1)-tuple of formal
psh functions a positive measure of finite mass on V. Next, we show that the
collection of Lelong numbers of a given germ u of a psh function at all
infinitely near points induces a formal psh function u' on V called its
valuative transform. When \phi is a psh Holder weight in the sense of Demailly,
the generalized Lelong number nu_\phi(u) equals the integral of u' against the
Monge-Ampere measure of the valuative transform of \phi. In particular, any
generalized Lelong number is an average of valuations. We also show how to
compute the multiplier ideal of u and the relative type of u with respect to
\phi in the sense of Rashkovskii, in terms of the valuative transforms of u and
\phi.
