#!/usr/bin/perl

while(<>){
    chop;
    push(@d, $_);
    if($#d > 3){
	print &variance(@d), "\n";
	shift(@d);
    }
}

sub variance {
    @v = @_;
    $av = &avg(@v);
    $tot = 0;
    $n = $#v+1;
    foreach $v (@v){
	$tot += ($v-$av)**2;
    }
    return $tot/$n;
}

sub avg {
    @v = @_;
    $n = $#v+1;
    $tot = 0;
    foreach $v (@v){
	$tot+=$v;
    }
    return $tot/$n;
}
