condDensLoop <- function(p, zMtx, model = "pairwiseBeta", par,
						predLoc = p, numInitPts = 201)
{
	#takes a series of p-dimensional observations (exceedances),
 	#hides the predLoc element of the observations, fits the 
 	#conditional density returns output for all observations
	
	numReps <- dim(zMtx)[1]
	
	zNotMtx <- matrix(nrow = numInitPts*2, ncol = numReps)
	zDensValMtx <- zNotMtx	
	cumTrapsMtx <- zNotMtx	
	smValsMtx <- zNotMtx
	xNotMtx <- zNotMtx
	xDensValMtx <- zNotMtx
	xConditionalExpVec <- numeric(numReps)	
	zActualMtx <- matrix(nrow = p, ncol = numReps)
	zArray <- array(dim = c(numInitPts*2, p, numReps))
	wArray <- zArray

	for(i in seq(1, numReps))
	{
		print(i)
		
		zNow <- zMtx[i,]
		temp <- condDensApprox(p, z = zNow, model = model,
					par = par, predLoc = predLoc, 
					numInitPts = numInitPts)
		numPts <- length(temp$zNot)
		zNotMtx[1:numPts,i] <- temp$zNot
		zDensValMtx[1:numPts,i] <- temp$zDensVal
		cumTrapsMtx[1:numPts,i] <- temp$cumTraps
		smValsMtx[1:numPts,i] <- temp$smVals
		xNotMtx[1:numPts,i] <- temp$xNot
		xDensValMtx[1:numPts,i] <- temp$xDensVal
		xConditionalExpVec[i] <- temp$xConditionalExp
		zActualMtx[,i] <- temp$zActual
		zArray[1:numPts,,i] <- temp$z
		wArray[1:numPts,,i] <- temp$w
	}
	
	rtn <- list()
	rtn$zNotMtx <- zNotMtx
	rtn$zDensValMtx <- zDensValMtx
	rtn$cumTrapsMtx <- cumTrapsMtx
	rtn$smValsMtx <- smValsMtx
	rtn$xNotMtx <- xNotMtx
	rtn$xDensValMtx <- xDensValMtx
	rtn$xConditionalExpVec <- xConditionalExpVec
	rtn$zActualMtx <- zActualMtx
	rtn$zArray <- zArray
	rtn$wArray <- wArray
	rtn$predLoc <- predLoc
	
	return(rtn)			
}
		
		
		