Index: trunk/psLib/test/dataManip/tst_psStats00.c
===================================================================
--- trunk/psLib/test/dataManip/tst_psStats00.c	(revision 659)
+++ trunk/psLib/test/dataManip/tst_psStats00.c	(revision 660)
@@ -1,4 +1,5 @@
 /*****************************************************************************
-    This code tests whether a hash table be allocated successfully.
+    This routine must ensure that PS_STAT_SAMPLE_MEAN is correctly computed
+    by the procedure psArrayStats().
  *****************************************************************************/
 #include <stdio.h>
@@ -14,7 +15,11 @@
     int i               = 0;
     psType dummyFloatType;
+    psType dummyIntType;
     psVector *myVector  = NULL;
+    psVector *maskVector= NULL;
     float mean          = 0.0;
-    float realMean      = 0.0;
+    float realMean1     = 0.0;
+    float realMean2     = 0.0;
+    int count           = 0;
 
     printPositiveTestHeader(stdout,
@@ -25,23 +30,43 @@
     dummyFloatType.type = PS_TYPE_FLOAT;
     dummyFloatType.dimen = PS_DIMEN_VECTOR;
+    dummyIntType.type = PS_TYPE_INT;
+    dummyIntType.dimen = PS_DIMEN_VECTOR;
     myVector = psVectorAlloc(dummyFloatType, N);
     myVector->n = N;
+    maskVector = psVectorAlloc(dummyIntType, N);
+    maskVector->n = N;
 
     mean = 0.0;
-    realMean = 0.0;
+    realMean2 = 0.0;
     for (i=0;i<N;i++) {
         myVector->vec.f[i] = (float) i;
-        realMean+= myVector->vec.f[i];
+        if (i < (N/2)) {
+            maskVector->vec.i[i] = 0;
+            realMean2+= myVector->vec.f[i];
+            count++;
+        } else {
+            printf("Masking element %d\n", i);
+            maskVector->vec.i[i] = 1;
+        }
+        realMean1+= myVector->vec.f[i];
     }
-    realMean /= (float) N;
+    realMean1 /= (float) N;
+    realMean2 /= (float) count;
 
     myStats2 = psArrayStats(myVector, NULL, 0, myStats);
     mean = myStats2->sampleMean;
 
-    if (mean == realMean) {
+    printf("Called psArrayStats() on a vector with no elements masked.\n");
+    printf("The expected mean was %f; the calculated mean was %f\n", realMean1, mean);
+    if (mean == realMean1) {
         testStatus = true;
     } else {
         testStatus = false;
     }
+
+    myStats2 = psArrayStats(myVector, maskVector, 1, myStats);
+    mean = myStats2->sampleMean;
+    printf("Called psArrayStats() on a vector with last N/2 elements masked.\n");
+    printf("The expected mean was %f; the calculated mean was %f\n", realMean2, mean);
 
     printFooter(stdout,
