starlite79
Technical User
Hi again.
I have a very large file (over 22000 records) for which I want to search for a field equaling 5.0, 6.0 and 7.0 (third field) and getting the count and average of the second field matching those 3 values. My code runs, but I don't trust the values I get. Could someone offer some help?
My output to screen looks like this:
average residual for 88 CERGA is -4.17045e-06
average residual for 88 MLRS2 is 5.92045e-06
average residual for 88 APACHE is -0.002412
I highly doubt that each of the three techniques have the same number of points (88), so I know something is not right.
I have a very large file (over 22000 records) for which I want to search for a field equaling 5.0, 6.0 and 7.0 (third field) and getting the count and average of the second field matching those 3 values. My code runs, but I don't trust the values I get. Could someone offer some help?
Code:
$3 == 5.0 { n = n + 1; cergares = cergares + $2 }
END { if ( n > 0 )
print " average residual for", n, "CERGA is", cergares/n
else
print "No CERGA data found"
}
$3 == 6.0 { n = n + 1; mlrs2res = mlrs2res + $2 }
END { if ( n > 0 )
print " average residual for", n, "MLRS2 is", mlrs2res/n
else
print "No MLRS2 data found"
}
$3 == 7.0 { n = n + 1; apacheres = apacheres + $2 }
END { if ( n > 0 )
print " average residual for", n, "APACHE is", apacheres/n
else
print "No APACHE data found"
}
My output to screen looks like this:
average residual for 88 CERGA is -4.17045e-06
average residual for 88 MLRS2 is 5.92045e-06
average residual for 88 APACHE is -0.002412
I highly doubt that each of the three techniques have the same number of points (88), so I know something is not right.