  We show how to obtain a Bayesian estimate of the rates or numbers of signal
and background events from a set of events when the shapes of the signal and
background distributions are known, can be estimated, or approximated; our
method works well even if the foreground and background event distributions
overlap significantly and the nature of any individual event cannot be
determined with any certainty. We give examples of determining the rates of
gravitational-wave events in the presence of background triggers from a
template bank when noise parameters are known and/or can be fit from the
trigger data. We also give an example of determining globular-cluster shape,
location, and density from an observation of a stellar field that contains a
non-uniform background density of stars superimposed on the cluster stars.
