We discuss models in which the smallness of the effective vacuum energy den
sity rho(Lambda) and the coincidence of the time of its dominance t(Lambda)
with the epoch of galaxy formation t(G) are due to anthropic selection eff
ects. In such models. the probability distribution for rho(Lambda) is a pro
duct of an a priori distribution P-*(rho(Lambda)) and of the number density
of galaxies at a given rho(Lambda) (which is proportional to the number of
observers who will detect that value of rho(Lambda)). To determine P-*, we
consider inflationary models in which the role of the vacuum energy is pla
yed by a slowly varying potential of some scalar field. We show that the re
sulting distribution depends on the shape of the potential and generally ha
s a non-trivial dependence on rho(Lambda), even in the narrow anthropically
allowed range. This is contrary to Weinberg's earlier conjecture that the
a priori distribution should be nearly flat in the range of interest. We ca
lculate the (final) probability distributions for rho(Lambda) and for t(G)/
t(Lambda) in simple models with power-law potentials. For some of these mod
els, the agreement with the observationally suggested values of rho(Lambda)
is better than with a Rat a priori distribution. We also discuss a quantum
-cosmological approach in which rho(Lambda) takes different values in diffe
rent disconnected universes and argue that Weinberg's conjecture is not val
id in this case as well. Finally, we extend our analysis to models of quint
essence, with similar conclusions.