From e1a72b24c4171e7b1434276aefff0603068de0b3 Mon Sep 17 00:00:00 2001
From: Vincent Danjean <Vincent.Danjean@ens-lyon.org>
Date: Tue, 23 May 2006 09:29:05 +0000
Subject: [PATCH] ajout quanti dans altree-add-S

git-svn-id: svn+ssh://imag/users/huron/danjean/svnroot/claire/altree/trunk@196 cf695345-040a-0410-a956-b889e835fe2e
---
 altree-add-S | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/altree-add-S b/altree-add-S
index 93b6721..dd1e7f7 100755
--- a/altree-add-S
+++ b/altree-add-S
@@ -91,7 +91,35 @@ sub calcul_moyenne_variance
     return ($moyenne, sqrt($variance));
 }
 
+sub calcul_moyenne_nbind
+{
+    my $tableau = shift;
+    
+    my $somme = 0;
+    my $nb_ind=scalar(@{$tableau});
+    foreach my $elem (@{$tableau}) {
+	$somme+=$elem;
+    }
+    return ($somme/$nb_ind, $nb_ind);
+}
+
+sub test_quanti_bilateral
+{
+    my $moy_gen = shift;
+    my $ec_type_gen = shift;
+    my $moy_loc = shift;
+    my $nb_ind_loc = shift;
+    my $epsilon = shift;
+
+    if ($moy_loc > ($moy_gen + $epsilon*$ec_type_gen/sqrt($nb_ind_loc))) {
+	return "eleve";
+    } elsif ($moy_loc < ($moy_gen - $epsilon*$ec_type_gen/sqrt($nb_ind_loc))) {
+	return "faible";
+    } else {
+	return "?";
+    }
 
+}
 
 sub travail
 {
@@ -268,9 +296,27 @@ sub travail
 			print STDERR "$nom is not found in the file". 
 			    "$name_correspond\n"; 	
 		    }
-		    my ($moyenne, $ec_type) = calcul_moyenne_variance($correspondance);
-		    print "Moyenne: $moyenne\n";
-		    print "Variance: $ec_type\n";
+		    my ($moyenne_gen, $ec_type) = calcul_moyenne_variance
+			($correspondance);
+		    my ($moyenne_loc, $nb_ind)= calcul_moyenne_nbind
+			($correspondance->{$nom});
+		    #DEBUG print "$nom\n";
+		    #DEBUG print "Moyenne: $moyenne_gen\n";
+		    #DEBUG print "Variance: $ec_type\n";
+		    #DEBUG print "Moyenne locale: $moyenne_loc\n";
+		    #DEBUG print "nb_ind: $nb_ind\n";
+		    if ($low !=0 && $nb_ind==1) {
+			$sequence.="?";
+		    }  else {
+			if (test_quanti_bilateral($moyenne_gen, $ec_type, $moyenne_loc, $nb_ind, $seuil) eq "eleve") {
+			    $sequence.=$mal;
+			} elsif (test_quanti_bilateral($moyenne_gen, $ec_type, $moyenne_loc, $nb_ind, $seuil) eq "faible") {
+			    $sequence.=$tem; 
+			} else {
+			    $sequence.="?";
+			}
+		    }
+		    print "$nom  ", $sequence, "\n";
 		}
 	    } 
 	}
-- 
GitLab