Generation of density perturbations in inflationary cosmology