## Compute Mann-Whitney statistics for the Voter Performance Protocol ## Fill in CURRENT results for the calibration system - must be at least 100 entries. ## Valid values are 0 thru 28. These arrays don't really need to be sorted, BTW. @cur_val = ( ## Example of how to enter the CURRENT results: 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,27,27,27,27, 27,26,26,26,26,26,26,26,26,26,22,22,22,22,22,22,21,21,21,21, 20,20,20,20,20,20,20,20,19,19,18,16,16,16,16,16,16,16,11, 9, 9, 2 ); @nom_val = ( ## Example of how to enter the NOMINAL results: ## The following numbers are fictitious examples for imaginary calibration systems ## Nominal values for System X 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27, 27,27,27,26,26,26,26,26,24,24,24,23,23,23,23,22,20,16,14,11 ## Nominal values for System Y - commented out ## 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, ## 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, ## 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,27,27,27, ## 27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,26,26,26,26, ## 26,25,25,25,24,23,23,23,23,22,22,20,20,20,20,15,14,13,13,02 ); $nom_size = scalar (@nom_val); $cur_size = scalar (@cur_val); print "\n#Nominal values = $nom_size; #Current values = $cur_size; \n"; print "\nWARNING: Array of current values has < 100 entries. \n" if ($cur_size < 100); print "\nWARNING: Array of nominal values has < 100 entries. \n" if ($nom_size < 100); # Compute U statistic $U = 0; foreach $this_nom (@nom_val) { die "\nERROR: Nominal value not in 0-28 range: $this_nom \n" if ($this_nom < 0 || $this_nom > 28); foreach $this_cur (@cur_val) { die "\nERROR: Current value not in 0-28 range: $this_cur \n" if ($this_cur < 0 || $this_cur > 28); if ($this_cur < $this_nom) { $U += 1; } elsif ($this_cur == $this_nom) { $U += 0.5; } } } # mean and Std. deviation for U $U_mean = $nom_size * $cur_size / 2; $U_std_dev = sqrt ($nom_size * $cur_size * ($nom_size + $cur_size + 1) / 12); $z = ($U - $U_mean) / $U_std_dev; printf "U = %8.1f; z-score = %8.4f \n", $U, $z; ## printf "U_mean = %8.3f; U_std_dev = %8.3f \n\n", $U_mean, $U_std_dev; $signif_95 = 1.96; # set for 95% confidence if ($z > 0 - $signif_95 && $z < $signif_95) { print "Z-score is within 95% confidence interval; test is valid. \n"; } else { print "Z-score is outside 95% confidence interval; test is invalid. \n"; }