We have derived the quasar luminosity function assuming that the quasar activity is driven by a thermal-viscous unstable accretion disk around a supermassive black hole . The instabilities produce large amplitude , long-term variability of a single source . We take a light curve of a single source and calculate the luminosity function , from the function of time it spends at each luminosity . Convolving this with an assumed mass distribution we fit well the observed optical luminosity function of quasars at four redshifts . As a result we obtain the evolution of the mass distribution between redshifts 2.5 and 0.5 . The main conclusions are following : 1 ) The quasar long-term variability due to the disk thermal-viscous instabilities provides a natural explanation for the observed quasar luminosity function . 2 ) The peak of the mass function evolves towards lower black hole masses at lower redshifts by a factor \sim 10 . 3 ) High mass sources die subsequently when redshift gets smaller . 4 ) The number of high mass sources declines rapidly , and so low mass sources become dominant at lower redshift . 5 ) The periodic outbursts of activity appear as long as the matter is supplied to the accretion disk . 6 ) Since the time-averaged accretion rate is low , the remnant sources ( or sources in the low activity phase ) do not grow to very massive black holes . 7 ) A continuous fuel supply at a relatively low accretion rate ( \sim 0.01 - 0.1 \dot { M } _ { Edd } ) for each single source is required over the lifetime of the entire quasar population .