Under the assumption that accretion on to massive black holes (BHs) powers active galactic nuclei (AGNs), the mass function (MF) of the BHs responsible for their past activity is estimated. For this, we take into account not only the activity related to the optically selected AGNs, but also that required to produce the hard X-ray background (HXRB). The MF of the massive dark objects (MDOs) in nearby quiescent galaxies is computed by means of the most recent results on their demography. The two mass functions match well under the assumption that the activity is concentrated in a single significant burst with lambdaLL_Edd being a weakly increasing function of luminosity. This behaviour may be indicative of some level of recurrence and/or of accretion rates insufficient to maintain the Eddington rates in low-luminosity/low-redshift objects. Our results support the scenario in which the early phase of intense nuclear activity occurred mainly in early-type galaxies (E/S0) during the relatively short period in which they still had an abundant interstellar medium. Only recently, with the decline of the quasi-stellar object (QSO) luminosities, did the activity in late-type galaxies (Sa/Sab) become statistically significant.