Calculating portfolio credit risk