#! /usr/bin/gawk -f BEGIN{ eraNum=1; stableCount=3; detectedClass= -1; totalCount=0; totalSum=0; k=NF} #for each ERA NR>0{ logMaxLikelihood = log($1); logMaxLikelihoods[instanceCount]=logMaxLikelihood; logMaxLikelihoodSum+=logMaxLikelihood; ++instanceCount if(NR%150==0) { eraMean=logMaxLikelihoodSum/150; for( ins in logMaxLikelihoods) { variance+=(logMaxLikelihoods[ins]-eraMean)**2 } erastDev=sqrt(variance/150); totalCount+=instanceCount; totalSum+=logMaxLikelihoodSum; totalMean=totalSum/totalCount; #print totalMean "\t" eraMean zr=Ztest(eraMean,totalMean,erastDev,totalCount); #print "\t" zr "\t" instanceCount "\t" totalCount if(zr<-4.2645){ print eraNum; } #if(stableCount >=3) #{ #print eraNum # ++detectedClass # detectedClassEra[detectedClass]=eraNum; #} # stableCount=0; #} ++eraNum; ++stableCount; delete logMaxLikelihoods; instanceCount=0; logMaxLikelihoodSum=0; } } function Ztest(newMean,oldMean,stDev,totInst){ if(stDev == 0) return newMean - oldMean; return (newMean-oldMean)/(stDev/sqrt(totInst)); }