The foundations of the Ensemble theory of credit portfolio modeling are laid in this article. We explain the concept of the ensemble and how to calculate conditional expectations in the ensemble framework from first principles. The results are applied to determine single obligor and joint default statistics conditional upon any level of portfolio loss analytically. The simplest of these is the conditional default rate which, in turn, yields the risk contribution to portfolio loss. The results also explain an optimal choice of probability transformation for importance sampling. The method gives financial institutions, credit portfolio managers and credit traders a detailed understanding of the risk allocation within their portfolios across the entire portfolio loss range.