private int calcNumberOfNodes(double serialProb, double pow2Prob, double uLow,
    				  double uMed, double uHi, double uProb) {
      
    	double u = random.nextDouble();
    	if (u <= serialProb) {// serial job 
    		return 1;
    	}
    	double par = twoStageUniform(uLow, uMed, uHi, uProb);
    	if (u <= (serialProb + pow2Prob)) {      // power of 2 nodes parallel job 
    		par = (int)(par + 0.5);              // par = round(par)
    	}

    	int numNodes = (int)(Math.pow(2, par) + 0.5);    // round(2^par)
    	int maxNodes = (int)(Math.pow(2, uHi) + 0.5);
    	return numNodes <= maxNodes ? numNodes : maxNodes; 
    }