#!/usr/bin/awk -f
# ----------------------------------------------
# When the line has data NF>1, in our case NF=6:
NF>1{
 t  =$2;       # current time
 x +=$3*$4;    # Σ_i     x * ρ(χ,t)
 x2+=$3*$3*$4  # Σ_i x * x * ρ(χ,t)
}
# A blank line separates datasets of different time:
NF<1{ 
 dx =0.02;     # put here the value of dx
 x *=dx;       # ~ ∫     x * ρ(χ,t) *  dx
 x2*=dx;       # ~ ∫ x * x * ρ(χ,t) *  dx
 DX =sqrt(x2-x*x); # Δx = sqrt( <x*x> - <x>*<x> ) 
 print t,x,x2,DX;
 x=0;x2=0;     # reset sums for the next dataset
}
