#!/usr/local/bin/gawk -f
# Input should be two columns, 
#   real model
# in milliseconds; each independently sorted and then abutted.
# (perhaps extracted by stripping the first columns from cdf files).
# We compute the running mean and rms value, allowing us to compute
# the demerit percentage for all cases up to that point.
# We output two columns:
#   real demerit%
# allowing a plot of the demerit percentage against the real values.
# $Id: running-demerit,v 2.0 94/07/17 18:33:46 dfk Exp $

{
    n++;
    sum += $1;
    sum_diff_squared += ($1 - $2)^2;

    mean_real = sum / n;
    rms = sqrt(sum_diff_squared / n);
    
    demerit_percent = 100. * rms/mean_real;

    print $1,demerit_percent
}
