[Swift-commit] r6123 - SwiftApps/SciColSim

wilde at ci.uchicago.edu wilde at ci.uchicago.edu
Thu Jan 3 18:24:00 CST 2013


Author: wilde
Date: 2013-01-03 18:24:00 -0600 (Thu, 03 Jan 2013)
New Revision: 6123

Modified:
   SwiftApps/SciColSim/sumloss.sh
Log:
Corrections to std dev calculation.

Modified: SwiftApps/SciColSim/sumloss.sh
===================================================================
--- SwiftApps/SciColSim/sumloss.sh	2013-01-04 00:23:21 UTC (rev 6122)
+++ SwiftApps/SciColSim/sumloss.sh	2013-01-04 00:24:00 UTC (rev 6123)
@@ -16,30 +16,35 @@
 {
   for(i=1;i<NF;i++)
   {
-      loss += $i
-      loss_sq += ($i*$i)
-      n++
+#printf "%12.5f\n", $i
+      sum_loss += $i
+      sum_lossSQ += ($i*$i)
+      nloss++
   }
-  tavg += $NF
-  tavg_sq += ($NF*$NF)
-  tn++
+  sum_time += $NF
+  sum_timeSQ += ($NF*$NF)
+  ntime++
 }
 
 END {
 
-  loss /= n;
-  loss_sq /= n;
-  tavg /= tn;
-  tavg_sq /= tn;
+  avg_loss = sum_loss / nloss;
+  avg_time = sum_time / ntime;
 
-  x = (loss_sq - (loss*loss))/n
-  y = (tavg_sq - ( tavg*tavg))/tn
-  if(x<0.0) x=0.0;
-  sdev = 2.0 * sqrt(x)
-  tsdev = 2.0 * sqrt(y)
+  var_loss = (sum_lossSQ - ((sum_loss*sum_loss)/nloss))/nloss
+  var_time = (sum_timeSQ - ((sum_time*sum_time)/ntime))/ntime
 
-  printf "loss sdev tavg tsdev\n"
-  printf "%f %f %f %f\n", loss, sdev, tavg, tsdev
+  if (var_loss<0.0) var_loss=0.0; # handle floating point roundoff
+  if (var_time<0.0) var_time=0.0; # handle floating point roundoff
+
+  sdev_loss = sqrt(var_loss)
+  sdev_time = sqrt(var_time)
+
+  serr_loss = 2.0 * sdev_loss;
+  serr_time = 2.0 * sdev_time;
+
+#printf "sum_loss=%f sum_lossSQ=%f\navg_loss=%f var_loss=%f\nsdev_loss=%f serr_loss=%f\n", sum_loss, sum_lossSQ, avg_loss, var_loss, sdev_loss, serr_loss
+
+  printf "loss sdev tavg tsdev\n" # header line must match Swift structure fields
+  printf "%f %f %f %f\n", avg_loss, serr_loss, avg_time, serr_time
 } ' $*
-
-# the awk script above implements this c++ logic from optimizer.cpp:




More information about the Swift-commit mailing list