private double[] calculateLosses(Credit[] portfolio,int horizon,int num){
  double[] losses=new double[num];
  for (int i=0; i < num; i++)   for (  Credit crd : portfolio) {
    int remDays=Math.min(crd.getRemainingTerm(),horizon);
    if (rndGen.nextDouble() >= 1 - crd.getDefaultProbability(remDays))     losses[i]+=(1 + crd.getAnnualRate() * Math.min(horizon,crd.getRemainingTerm()) / 365) * crd.getRemainingAmount();
 else     losses[i]-=crd.getAnnualRate() * Math.min(horizon,crd.getRemainingTerm()) / 365 * crd.getRemainingAmount();
  }
  return losses;
}

private double [ ] calculateLosses ( Credit [ ] portfolio , int horizon , int num ) { double [ ] losses = new double [ num ] ; for ( int i = 0 ; i < num ; i ++ ) for ( Credit crd : portfolio ) { int remDays = Math . min ( crd . getRemainingTerm ( ) , horizon ) ; if ( rndGen . nextDouble ( ) >= 1 - crd . getDefaultProbability ( remDays ) ) losses [ i ] += ( 1 + crd . getAnnualRate ( ) * Math . min ( horizon , crd . getRemainingTerm ( ) ) / 365 ) * crd . getRemainingAmount ( ) ; else losses [ i ] -= crd . getAnnualRate ( ) * Math . min ( horizon , crd . getRemainingTerm ( ) ) / 365 * crd . getRemainingAmount ( ) ; } return losses ; }
calculates losses for the given credit portfolio using monte - carlo simulation . simulates probability of default only .
