The current knowledge on the stellar IMF is documented. It appears to become top-heavy when the star-formation rate density surpasses about 0.1Msun/(yr pc^3) on a pc scale and it may become increasingly bottom-heavy with increasing metallicity and in increasingly massive early-type galaxies. It declines quite steeply below about 0.07Msun with brown dwarfs (BDs) and very low mass stars having their own IMF. The most massive star of mass mmax formed in an embedded cluster with stellar mass Mecl correlates strongly with Mecl being a result of gravitation-driven but resource-limited growth and fragmentation induced starvation. There is no convincing evidence whatsoever that massive stars do form in isolation. Various methods of discretising a stellar population are introduced: optimal sampling leads to a mass distribution that perfectly represents the exact form of the desired IMF and the mmax-to-Mecl relation, while random sampling results in statistical variations of the shape of the IMF. The observed mmax-to-Mecl correlation and the small spread of IMF power-law indices together suggest that optimally sampling the IMF may be the more realistic description of star formation than random sampling from a universal IMF with a constant upper mass limit. Composite populations on galaxy scales, which are formed from many pc scale star formation events, need to be described by the integrated galactic IMF. This IGIMF varies systematically from top-light to top-heavy in dependence of galaxy type and star formation rate, with dramatic implications for theories of galaxy formation and evolution.