#! /usr/bin/gawk -f BEGIN{ FS=","; k=0; } i<=150 && NR>0{ #caluculate the new mean old mean,stdDev #print NR era+=log($1); train[NR]+=log($1); trainMean[NR]=train[NR]/NR trainSumS= (log($1)-trainMean[NR])*(log($1)-trainMean[NR]) #itraindev[NR]=trainSumS[NR]/NR i++ if((NR)%150==0) { i=0; d[instant_count]=NR; eraMean[instant_count]=era/150; eraDev[instant_count]=(trainSumS/150); #print instant_count #instant_count++; if((z=Ztest(eraMean[instant_count],trainMean[NR],eraDev[instant_count],NR))<-4.2645) { print z #check for stability for 3 era and note down the first one print NR #print instant_count } instant_count++ era=0 trianSumS=0; } d[instant_count]=NR } END{ #for(i in trainMean) #print i "\t" trainMean[i] "\t" train[i] "\t" traindev[i] for (k in eraMean) { print d[k] "\t" eraMean[k]} } function Ztest(newMean,oldMean,stDev,totInst){ if(stDev == 0) return newMean - oldMean; return (newMean-oldMean)/(stDev/sqrt(totInst)); }