We derive an analytical theory of the prestellar core initial mass function based on an extension of the Press-Schechter statistical formalism applied in cosmology . Our approach relies on the general concept of the gravo-thermal and gravo-turbulent collapse of a molecular cloud , with a selection criterion based on the thermal or turbulent Jeans mass , which yields the derivation of the mass spectrum of self-gravitating objects in a quiescent or a turbulent environment . With the same formalism , simply by using a constant density threshold for the selection criterion , we also obtain the mass spectrum for the non self-gravitating clumps produced in supersonic flows . The mass spectrum of the self-gravitating cores reproduces very well the observed initial mass function , from the high mass domain to the brown dwarf regime , and identifies the different underlying mechanisms responsible for its behaviour . The theory predicts that the shape of the IMF results from two competing contributions , namely a power-law at large scales and an exponential cut-off ( lognormal form ) centered around the characteristic mass for gravitational collapse condition . The cut-off is not specifically due to turbulence and exists already in the case of pure thermal collapse , provided that the underlying density field has a lognormal distribution . Whereas pure thermal collapse produces a power-law tail steeper than the Salpeter value , dN / d \log M \propto M ^ { - x } with x \simeq 1.35 , this latter is recovered exactly for the ( 3D ) value of the spectral index of the velocity power spectrum , n \simeq 3.8 , found in observations and in numerical simulations of isothermal supersonic turbulence . Indeed , the theory predicts that x = ( n + 1 ) / ( 2 n - 4 ) for self-gravitating structures and x = 2 - n ^ { \prime } / 3 for non self-gravitating structures , where n ^ { \prime } is the power spectrum index of \log \rho . We show that , whereas supersonic turbulence promotes the formation of both massive stars and brown dwarfs , it has an overall negative impact on star formation , decreasing the star formation efficiency . This theory provides a novel theoretical foundation to understand the origin of the IMF and to infer its behaviour in different environment , characterized by the local properties of the gas , from today Galactic conditions to the ones prevailing at high redshift . As for the Press-Schechter theory in cosmology , the present theory provides a complementary approach and useful guidance to numerical simulations exploring star formation , while making testable predictions .