#!/usr/bin/perl

while ($reading=<STDIN>) {

	if (substr($reading,0,1) =~ "[0-9]") {
		($x,$y) = split(/\s/,$reading);
		if ($y == $last) { $y = $y + 1e-15;}
		$N = push(@phase,$y);
	}
}

# Overlapping Allan Deviation
# Sigma^2(Tau) = 
# 1 / (2*(N-2*m)*Tau^2) * Sum(X[i+2*m]-2*X[i+m]+X[i], i=1, i=N-2*m)
# Tau is the averaging time, N is the total number of points,
# and Tau = m*Tau0, where Tau0 is the basic measurement interval       

$tau0 = 600;

for ($m = 1; $m <= ($N-1)/2; $m++) {
	$tau = $m*$tau0;
	$sigma = 0;
	$NumGaps = 0;
           
	for($i = 0; $i < ($N-2*$m); $i++) {
		$sum = 0;
		if(($phase[$i+2*$m]==0 ||  $phase[$i+$m]==0 || $phase[$i]==0) 
			&& $i!=0 && $i!=($N-2*$m-1)) {
				$numGaps++;
			} else {
				$sum = $phase[$i+2*$m] - 2*$phase[$i+$m]
			    	   	+ $phase[$i];
				$sigma += $sum * $sum;
			}
	}
              
	$sigma = $sigma / (2.0*($N-$numGaps-2*$m)*$tau*$tau);
	$sigma = sqrt($sigma);
	print "$tau $sigma\n";
}
