[LON-CAPA-cvs] cvs: modules /gerd/discussions studeval.pl
www
lon-capa-cvs@mail.lon-capa.org
Wed, 13 Apr 2005 20:32:46 -0000
www Wed Apr 13 16:32:46 2005 EDT
Modified files:
/modules/gerd/discussions studeval.pl
Log:
First student-based stats
Index: modules/gerd/discussions/studeval.pl
diff -u modules/gerd/discussions/studeval.pl:1.1 modules/gerd/discussions/studeval.pl:1.2
--- modules/gerd/discussions/studeval.pl:1.1 Sun Apr 10 19:01:24 2005
+++ modules/gerd/discussions/studeval.pl Wed Apr 13 16:32:46 2005
@@ -76,6 +76,7 @@
my %statn=();
my %statsumsquare=();
+my @bins=0;
#
# Compute means and errors
#
@@ -83,7 +84,9 @@
foreach my $error (0,1) {
foreach (@q) {
my @entries=split(/\,/,$_);
-
+ unless ($error) { $bins[$entries[$sumall]]++; }
+ &callabssums('sumall&all',$error,@entries);
+ &callabssums('sumall&gender'.$entries[$gender],$error,@entries);
}
}
@@ -92,9 +95,54 @@
#
print "\n";
+for (my $i=0; $i<=$#bins; $i++) {
+ print "\n".$i.','.$bins[$i];
+}
+print "\n";
+
+# All and by gender
+print "\nAve number postings: ".&reportoutabs('sumall&all');
+print "\nAve number postings male: ".&reportoutabs('sumall&genderm');
+print "\nAve number postings female: ".&reportoutabs('sumall&genderf');
+print "\n";
# ======== End analysis, subroutines
+sub callabssums {
+ my ($which,$error,@entries)=@_;
+ unless ($error) {
+ &meanabssum($which,@entries);
+ } else {
+ &meanabssumsquared($which,@entries);
+ }
+}
+
+sub meanabssum {
+ my ($which,@entries)=@_;
+ $statn{$which}++;
+ my ($routine,$cat)=split(/\&/,$which);
+ no strict 'refs';
+ my $num=&$routine(@entries);
+ use strict 'refs';
+ $statsum{$which}+=$num;
+}
+
+sub meanabssumsquared {
+ my ($which,@entries)=@_;
+ unless ($statn{$which}) { return; }
+ my ($routine,$cat)=split(/\&/,$which);
+ no strict 'refs';
+ my $num=&$routine(@entries);
+ use strict 'refs';
+ $statsumsquare{$which}+=($num-$statsum{$which}/$statn{$which})**2;
+}
+
+sub reportoutabs {
+ my $which=shift;
+ my $ave=$statsum{$which}/$statn{$which};
+ my $err=sqrt($statsumsquare{$which}/($statn{$which}*($statn{$which}-1)));
+ return $ave.', '.$err;
+}
sub callsums {
my ($which,$error,@entries)=@_;
@@ -194,6 +242,12 @@
return $sum;
}
+
+sub sumall {
+ my @entries=@_;
+ return $entries[$sumall];
+}
+
sub solution {
my @entries=@_;
return &solution_question(@entries)