$ cat data.HW2 1.1 2.1 3.1 4.1 1.2 2.2 3.2 4.2 1.3 2.3 3.3 4.3 1.4 2.4 3.4 4.4 #### cat jackkinfe.pl #! /usr/bin/perl use warnings; use strict; my @n=0; my @x; my $j; my $i; my $dg; my @x_jack; my @x_tot=0; my $cols; my $col_start=0; # read in the data while(<>) { my @column = split(); $cols=@column; foreach my $j ($col_start .. $#column) { $x[$n[$j]][$j] = $column[$j]; $x_tot[$j] += $x[$n[$j]][$j]; $n[$j]++; } } # Do the jackknife estimates for ($j=$col_start; $j<$cols; $j++) { for ($i = 0; $i < $n[$j]; $i++) { $x_jack[$i][$j] = ($x_tot[$j] - $x[$i][$j]) / ($n[$j] - 1); } # Do the final jackknife estimate my @g_jack_av=0; my @g_jack_err=0; for ($i = 0; $i < $n[$j]; $i++) { $dg = $x_jack[$i][$j]; $g_jack_av[$j] += $dg; $g_jack_err[$j] += $dg**2; } $g_jack_av[$j] /= $n[$j]; $g_jack_err[$j] /= $n[$j]; $g_jack_err[$j] = sqrt(($n[$j] - 1) * abs($g_jack_err[$j] - $g_jack_av[$j]**2)); printf "%e %e ", $g_jack_av[$j], $g_jack_err[$j]; } printf "\n"; #### $cat data.HW2 | perl jackknife.pl Use of uninitialized value within @n in array element at cols_jacknife.pl line 19, <> line 1. Use of uninitialized value within @n in array element at cols_jacknife.pl line 20, <> line 1. #### $x[$n[$j]][$j] = $column[$j]; $x_tot[$j] += $x[$n[$j]][$j];