#!/usr/local/bin/perl # eb.p file1 # takes takeuchi's error bar file N z delta and also dat1 # and returns N residual # to leave out first two points and # get chi^2 without offset, # eb.p null=0 leave=2 z $leave=0; $null = 10000 ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $i=0; open ( DAT , " ) && ( $dat = ) ) { # $i++; $dat =~ /^\s*([\-\d\.]+)\s+([\-\d\.]+)\s*\n/ ; $d = $2 ; /^\s*([\-\d\.]+)[\s\t]+([\-\d\.]+)[\s\t]+([\-\d\.]+)\s*\n/ ; # /^\s*([\-\d\.]+)[\s\t]+([\-\d\.]+)[\s\n]/ ; $eb = $3 ; $res = $2 - $d ; printf ( "$1\t%f\n" , $2 - $d ) ; if ( $i <= $leave ) { next LINE ; } $count ++ ; # $ss += $res * $res ; $term = $res * $res / ( $eb * $eb + $null ) ; $chi2 += $term ; if ( $term > 4.0 ) { print STDERR $i," : " , $res/$eb , "\n" ; $over ++; } # printf STDERR ( "$1\t%f\t%f\n" , $2 , $d ) ; # $count ++ ; } # $ss /= $count ; printf STDERR "$count : $over over; rms residual = %6.4f, chi2 = %6.4f\n" , sqrt( $ss ) , $chi2 ; if ( $leave > 0 ) { printf STDERR "NB RMS residual of included points only\n";}