A Bayesian hierarchical model for simultaneously estimating and partitioning probability density functions is presented. Individual density functions are flexibly modeled using Bernstein densities, which are mixtures of beta densities whose parameters depend only on the number of mixture components. A prior distribution is placed on the number of mixture components, and the mixture weights are expressed as increments of a distribution function G. A Dirichlet process prior is placed on G and the parameters of the Dirichlet process, the baseline distribution and the precision parameter, are treated as random. A mixture of a product of beta densities is used to partition subjects into groups, with subjects in the same group sharing information via a common baseline distribution. Inference is carried out using Markov chain Monte Carlo. A computing algorithm based on the constructive definition of the Dirichlet process is offered, for both a fixed number of groups and an unknown number of groups. When the number of groups is unknown, a birth–death algorithm is used to make inference regarding the number of groups. The model is demonstrated using radiologist-specific distributions of percent mammographic density.