Index: /trunk/psLib/src/dataManip/psRandom.h
===================================================================
--- /trunk/psLib/src/dataManip/psRandom.h	(revision 2779)
+++ /trunk/psLib/src/dataManip/psRandom.h	(revision 2780)
@@ -10,12 +10,12 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-11-24 20:55:01 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-12-21 23:25:14 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 */
 
-#if !defined(PS_FUNCTIONS_H)
-#define PS_FUNCTIONS_H
+#if !defined(PS_RANDOM_H)
+#define PS_RANDOM_H
 
 #include <stdio.h>
Index: /trunk/psLib/src/dataManip/psStats.c
===================================================================
--- /trunk/psLib/src/dataManip/psStats.c	(revision 2779)
+++ /trunk/psLib/src/dataManip/psStats.c	(revision 2780)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.105 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-21 20:42:07 $
+ *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-21 23:25:14 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -151,4 +151,5 @@
                          psStats* stats)
 {
+
     psS32 i = 0;                // Loop index variable
     float mean = 0.0;           // The mean
@@ -920,5 +921,7 @@
                     sumDiffs += diff;
                     countInt++;
-                    errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    if (errors != NULL) {
+                        errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    }
                 }
             }
@@ -931,5 +934,7 @@
                     sumDiffs += diff;
                     countInt++;
-                    errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    if (errors != NULL) {
+                        errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    }
                 }
             }
@@ -944,5 +949,7 @@
                     sumDiffs += diff;
                     countInt++;
-                    errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    if (errors != NULL) {
+                        errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    }
                 }
             }
@@ -955,5 +962,7 @@
             }
             countInt = myVector->n;
-            errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+            if (errors != NULL) {
+                errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+            }
         }
     }
@@ -1962,4 +1971,7 @@
 psVector* p_psConvertToF32(psVector* in)
 {
+    if (in == NULL) {
+        return(NULL);
+    }
     psS32 i = 0;
     psVector* tmp = NULL;
Index: /trunk/psLib/src/math/psRandom.h
===================================================================
--- /trunk/psLib/src/math/psRandom.h	(revision 2779)
+++ /trunk/psLib/src/math/psRandom.h	(revision 2780)
@@ -10,12 +10,12 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-11-24 20:55:01 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-12-21 23:25:14 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 */
 
-#if !defined(PS_FUNCTIONS_H)
-#define PS_FUNCTIONS_H
+#if !defined(PS_RANDOM_H)
+#define PS_RANDOM_H
 
 #include <stdio.h>
Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 2779)
+++ /trunk/psLib/src/math/psStats.c	(revision 2780)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.105 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-21 20:42:07 $
+ *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-21 23:25:14 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -151,4 +151,5 @@
                          psStats* stats)
 {
+
     psS32 i = 0;                // Loop index variable
     float mean = 0.0;           // The mean
@@ -920,5 +921,7 @@
                     sumDiffs += diff;
                     countInt++;
-                    errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    if (errors != NULL) {
+                        errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    }
                 }
             }
@@ -931,5 +934,7 @@
                     sumDiffs += diff;
                     countInt++;
-                    errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    if (errors != NULL) {
+                        errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    }
                 }
             }
@@ -944,5 +949,7 @@
                     sumDiffs += diff;
                     countInt++;
-                    errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    if (errors != NULL) {
+                        errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+                    }
                 }
             }
@@ -955,5 +962,7 @@
             }
             countInt = myVector->n;
-            errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+            if (errors != NULL) {
+                errorDivisor+= (1.0 / PS_SQR(errors->data.F32[i]));
+            }
         }
     }
@@ -1962,4 +1971,7 @@
 psVector* p_psConvertToF32(psVector* in)
 {
+    if (in == NULL) {
+        return(NULL);
+    }
     psS32 i = 0;
     psVector* tmp = NULL;
Index: /trunk/psLib/test/dataManip/Makefile
===================================================================
--- /trunk/psLib/test/dataManip/Makefile	(revision 2779)
+++ /trunk/psLib/test/dataManip/Makefile	(revision 2780)
@@ -3,6 +3,6 @@
 ##  Makefile:   test/sysUtils
 ##
-##  $Revision: 1.53 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-12-20 19:33:53 $
+##  $Revision: 1.54 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-12-21 23:24:49 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -57,4 +57,5 @@
 tst_psStats08 \
 tst_psStats09 \
+tst_psRandom \
 tst_psVectorFFT 
 # tst_psFunc06 \
Index: /trunk/psLib/test/dataManip/tst_psHist02.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psHist02.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psHist02.c	(revision 2780)
@@ -66,5 +66,5 @@
 
         myHist = psHistogramAlloc( LOWER, UPPER, numBins );
-        myHist = psVectorHistogram( myHist, myData, NULL, 0 );
+        myHist = psVectorHistogram( myHist, myData, NULL, NULL, 0 );
 
         for ( i = 0;i < numBins;i++ ) {
@@ -91,5 +91,5 @@
 
         myHist = psHistogramAlloc( LOWER, UPPER, numBins );
-        myHist = psVectorHistogram( myHist, myData, myMask, 1 );
+        myHist = psVectorHistogram( myHist, myData, NULL, myMask, 1 );
 
         for ( i = 0;i < numBins;i++ ) {
@@ -121,5 +121,5 @@
 
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message.");
-    myHist2 = psVectorHistogram( NULL, myData, NULL, 0 );
+    myHist2 = psVectorHistogram( NULL, myData, NULL, NULL, 0 );
     if ( myHist2 != NULL ) {
         printf( "ERROR: myHist2!=NULL\n" );
@@ -136,5 +136,5 @@
     myHist = psHistogramAlloc( LOWER, UPPER, numBins );
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message.");
-    myHist = psVectorHistogram( myHist, NULL, NULL, 0 );
+    myHist = psVectorHistogram( myHist, NULL, NULL, NULL, 0 );
     if ( myHist == NULL ) {
         printf( "ERROR: myHist==NULL\n" );
@@ -155,5 +155,5 @@
     myData->n = myData->nalloc;
     myHist = psHistogramAlloc(LOWER, UPPER, numBins);
-    myHist = psVectorHistogram(myHist, NULL, NULL, 0);
+    myHist = psVectorHistogram(myHist, NULL, NULL, NULL, 0);
     if (myHist == NULL) {
         printf("ERROR: myHist==NULL\n");
Index: /trunk/psLib/test/dataManip/tst_psHist03.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psHist03.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psHist03.c	(revision 2780)
@@ -89,5 +89,5 @@
         }
 
-        myHist = psVectorHistogram( myHist, myData, NULL, 0 );
+        myHist = psVectorHistogram( myHist, myData, NULL, NULL, 0 );
         for (i=0;i<numBins;i++) {
             printf("Bin number %d bounds: (%6.3f - %6.3f): data: (%d)\n", i,
Index: /trunk/psLib/test/dataManip/tst_psRandom.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psRandom.c	(revision 2780)
+++ /trunk/psLib/test/dataManip/tst_psRandom.c	(revision 2780)
@@ -0,0 +1,411 @@
+/*****************************************************************************
+This routine must ensure that the various random number generator functions
+work properly.
+ 
+    t00(): ensure that psRandom structs are properly allocated by psRandomAlloc().
+    t01(): ensure that psRandomUniform() produces a sequence of numbers with
+    proper mean and stdev.
+    t02(): ensure that psRandomGaussian() produces a sequence of numbers with
+    proper mean and stdev.
+    t03(): ensure that psRandomPoisson() produces a sequence of numbers with
+    proper mean and stdev.
+    t04(): ensure that psRandomReset() properly seeds the random number
+    generator for psRandomUniform().
+    t05(): ensure that psRandomReset() properly seeds the random number
+    generator for psRandomGaussian().
+    t06(): ensure that psRandomReset() properly seeds the random number
+    generator for psRandomPoisson().
+ *****************************************************************************/
+#include <stdio.h>
+#include <math.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psMemory.h"
+#include "psVector.h"
+#include "psRandom.h"
+#define NUM_DATA 10000
+#define SEED 54321
+#define SEED2 345
+#define UNIFORM_MEAN 0.5
+#define UNIFORM_STDEV 0.3
+#define GAUSSIAN_MEAN 0.0
+#define GAUSSIAN_STDEV 1.0
+#define POISSON_MEAN 15.0
+#define POISSON_STDEV (POISSON_MEAN / 4)
+#define ERROR_TOLERANCE 0.1
+psS32 testStatus = true;
+
+psS32 t00()
+{
+    psRandom *myRNG = NULL;
+    psS32 currentId = psMemGetId();
+    psS32 memLeaks = 0;
+
+    printPositiveTestHeader(stdout,
+                            "psRandom functions",
+                            "psRandomAlloc()");
+
+    myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
+    if (myRNG == NULL) {
+        printf("ERROR: Could not allocate psRandom structure\n");
+        testStatus = false;
+    }
+
+    psMemCheckCorruption(1);
+    psFree(myRNG);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psRandom functions",
+                "psRandomAlloc()",
+                testStatus);
+
+    return(testStatus);
+}
+
+psS32 t01()
+{
+    psRandom *myRNG = NULL;
+    psS32 currentId = psMemGetId();
+    psS32 memLeaks = 0;
+    psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+
+    printPositiveTestHeader(stdout,
+                            "psRandom functions",
+                            "psRandomAlloc() and psRandomUniform()");
+
+    myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
+    if (myRNG == NULL) {
+        printf("ERROR: Could not allocate psRandom structure\n");
+        testStatus = false;
+    }
+
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans->data.F64[i] = psRandomUniform(myRNG);
+        //        printf("%f\n", rans->data.F64[i]);
+    }
+    stats = psVectorStats(stats, rans, NULL, NULL, 0);
+    printf("Mean is %f\n", stats->sampleMean);
+    stats->options = PS_STAT_SAMPLE_STDEV;
+    stats = psVectorStats(stats, rans, NULL, NULL, 0);
+    printf("Standard deviation is %f\n", stats->sampleStdev);
+    if ((fabs(stats->sampleMean - UNIFORM_MEAN) / UNIFORM_MEAN) > ERROR_TOLERANCE) {
+        printf("ERROR: psRandomUniform() mean is %f, should be %f\n", stats->sampleMean, UNIFORM_MEAN);
+        testStatus = false;
+    }
+    if ((fabs(stats->sampleStdev - UNIFORM_STDEV) / UNIFORM_STDEV) > ERROR_TOLERANCE) {
+        printf("ERROR: psRandomUniform() stdev is %f, should be %f\n", stats->sampleStdev, UNIFORM_STDEV);
+        testStatus = false;
+    }
+
+    psMemCheckCorruption(1);
+    psFree(myRNG);
+    psFree(rans);
+    psFree(stats);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psRandom functions",
+                "psRandomAlloc() and psRandomUniform()",
+                testStatus);
+
+    return(testStatus);
+}
+
+psS32 t02()
+{
+    psRandom *myRNG = NULL;
+    psS32 currentId = psMemGetId();
+    psS32 memLeaks = 0;
+    psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+
+    printPositiveTestHeader(stdout,
+                            "psRandom functions",
+                            "psRandomAlloc() and psRandomGaussian()");
+
+    myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
+    if (myRNG == NULL) {
+        printf("ERROR: Could not allocate psRandom structure\n");
+        testStatus = false;
+    }
+
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans->data.F64[i] = psRandomGaussian(myRNG);
+        //        printf("%f\n", rans->data.F64[i]);
+    }
+    stats = psVectorStats(stats, rans, NULL, NULL, 0);
+    printf("Mean is %f\n", stats->sampleMean);
+    stats->options = PS_STAT_SAMPLE_STDEV;
+    stats = psVectorStats(stats, rans, NULL, NULL, 0);
+    printf("Standard deviation is %f\n", stats->sampleStdev);
+    if ((fabs(stats->sampleMean - GAUSSIAN_MEAN) / 1.0) > ERROR_TOLERANCE) {
+        printf("ERROR: psRandomUniform() mean is %f, should be %f\n", stats->sampleMean, GAUSSIAN_MEAN);
+        testStatus = false;
+    }
+    if ((fabs(stats->sampleStdev - GAUSSIAN_STDEV) / GAUSSIAN_STDEV) > ERROR_TOLERANCE) {
+        printf("ERROR: psRandomUniform() stdev is %f, should be %f\n", stats->sampleStdev, GAUSSIAN_STDEV);
+        testStatus = false;
+    }
+
+    psMemCheckCorruption(1);
+    psFree(myRNG);
+    psFree(rans);
+    psFree(stats);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psRandom functions",
+                "psRandomAlloc() and psRandomGaussian()",
+                testStatus);
+
+    return(testStatus);
+}
+
+psS32 t03()
+{
+    psRandom *myRNG = NULL;
+    psS32 currentId = psMemGetId();
+    psS32 memLeaks = 0;
+    psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+
+    printPositiveTestHeader(stdout,
+                            "psRandom functions",
+                            "psRandomAlloc() and psRandomPoisson()");
+
+    myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
+    if (myRNG == NULL) {
+        printf("ERROR: Could not allocate psRandom structure\n");
+        testStatus = false;
+    }
+
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
+        //        printf("%f\n", rans->data.F64[i]);
+    }
+    stats = psVectorStats(stats, rans, NULL, NULL, 0);
+    printf("Mean is %f\n", stats->sampleMean);
+    stats->options = PS_STAT_SAMPLE_STDEV;
+    stats = psVectorStats(stats, rans, NULL, NULL, 0);
+    printf("Standard deviation is %f\n", stats->sampleStdev);
+    if ((fabs(stats->sampleMean - POISSON_MEAN) / POISSON_MEAN) > ERROR_TOLERANCE) {
+        printf("ERROR: psRandomUniform() mean is %f, should be %f\n", stats->sampleMean, POISSON_MEAN);
+        testStatus = false;
+    }
+    if ((fabs(stats->sampleStdev - POISSON_STDEV) / POISSON_STDEV) > ERROR_TOLERANCE) {
+        printf("ERROR: psRandomUniform() stdev is %f, should be %f\n", stats->sampleStdev, POISSON_STDEV);
+        testStatus = false;
+    }
+
+
+    psMemCheckCorruption(1);
+    psFree(myRNG);
+    psFree(rans);
+    psFree(stats);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psRandom functions",
+                "psRandomAlloc() and psRandomPoisson()",
+                testStatus);
+
+    return(testStatus);
+}
+
+psS32 t04()
+{
+    psRandom *myRNG = NULL;
+    psS32 currentId = psMemGetId();
+    psS32 memLeaks = 0;
+    psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psVector *rans01 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psVector *rans02 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+
+    printPositiveTestHeader(stdout,
+                            "psRandom functions",
+                            "psRandomAlloc(), psRandomReset(), and psRandomUniform()");
+    myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
+    if (myRNG == NULL) {
+        printf("ERROR: Could not allocate psRandom structure\n");
+        testStatus = false;
+    }
+    psRandomReset(myRNG, SEED);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans00->data.F64[i] = psRandomUniform(myRNG);
+    }
+    psRandomReset(myRNG, SEED2);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans01->data.F64[i] = psRandomUniform(myRNG);
+    }
+    psRandomReset(myRNG, SEED);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans02->data.F64[i] = psRandomUniform(myRNG);
+    }
+
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        if (rans00->data.F64[i] != rans02->data.F64[i]) {
+            printf("ERROR: psRandomUniform() did not produce the same results with the same seed\n");
+        }
+    }
+
+    psMemCheckCorruption(1);
+    psFree(myRNG);
+    psFree(rans00);
+    psFree(rans01);
+    psFree(rans02);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psRandom functions",
+                "psRandomAlloc(), psRandomReset(), and psRandomUniform()",
+                testStatus);
+
+    return(testStatus);
+}
+
+psS32 t05()
+{
+    psRandom *myRNG = NULL;
+    psS32 currentId = psMemGetId();
+    psS32 memLeaks = 0;
+    psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psVector *rans01 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psVector *rans02 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+
+    printPositiveTestHeader(stdout,
+                            "psRandom functions",
+                            "psRandomAlloc(), psRandomReset(), and psRandomGaussian()");
+    myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
+    if (myRNG == NULL) {
+        printf("ERROR: Could not allocate psRandom structure\n");
+        testStatus = false;
+    }
+    psRandomReset(myRNG, SEED);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans00->data.F64[i] = psRandomGaussian(myRNG);
+    }
+    psRandomReset(myRNG, SEED2);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans01->data.F64[i] = psRandomGaussian(myRNG);
+    }
+    psRandomReset(myRNG, SEED);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans02->data.F64[i] = psRandomGaussian(myRNG);
+    }
+
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        if (rans00->data.F64[i] != rans02->data.F64[i]) {
+            printf("ERROR: psRandomGaussian() did not produce the same results with the same seed\n");
+        }
+    }
+
+    psMemCheckCorruption(1);
+    psFree(myRNG);
+    psFree(rans00);
+    psFree(rans01);
+    psFree(rans02);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psRandom functions",
+                "psRandomAlloc(), psRandomReset(), and psRandomGaussian()",
+                testStatus);
+
+    return(testStatus);
+}
+
+psS32 t06()
+{
+    psRandom *myRNG = NULL;
+    psS32 currentId = psMemGetId();
+    psS32 memLeaks = 0;
+    psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psVector *rans01 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+    psVector *rans02 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
+
+    printPositiveTestHeader(stdout,
+                            "psRandom functions",
+                            "psRandomAlloc(), psRandomReset(), and psRandomPoisson()");
+    myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
+    if (myRNG == NULL) {
+        printf("ERROR: Could not allocate psRandom structure\n");
+        testStatus = false;
+    }
+    psRandomReset(myRNG, SEED);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans00->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
+    }
+    psRandomReset(myRNG, SEED2);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans01->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
+    }
+    psRandomReset(myRNG, SEED);
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        rans02->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
+    }
+
+    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
+        if (rans00->data.F64[i] != rans02->data.F64[i]) {
+            printf("ERROR: psRandomPoisson() did not produce the same results with the same seed\n");
+        }
+    }
+
+    psMemCheckCorruption(1);
+    psFree(myRNG);
+    psFree(rans00);
+    psFree(rans01);
+    psFree(rans02);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psRandom functions",
+                "psRandomAlloc(), psRandomReset(), and psRandomPoisson()",
+                testStatus);
+
+    return(testStatus);
+}
+
+psS32 main()
+{
+    testStatus = true;
+
+    t00();
+    t01();
+    t02();
+    t03();
+    t04();
+    t05();
+    t06();
+
+    return(!testStatus);
+}
Index: /trunk/psLib/test/dataManip/tst_psStats00.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats00.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psStats00.c	(revision 2780)
@@ -63,5 +63,5 @@
                             "PS_STAT_SAMPLE_MEAN: no vector mask");
 
-    myStats = psVectorStats(myStats, myVector, NULL, 0);
+    myStats = psVectorStats(myStats, myVector, NULL, NULL, 0);
     mean = myStats->sampleMean;
 
@@ -86,5 +86,5 @@
                             "PS_STAT_SAMPLE_MEAN: with vector mask=1");
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 1);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 1);
     mean = myStats->sampleMean;
     printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
@@ -117,5 +117,5 @@
     }
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 2);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 2);
     mean = myStats->sampleMean;
     printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
@@ -148,5 +148,5 @@
     }
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 3);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 3);
     mean = myStats->sampleMean;
     printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
@@ -173,10 +173,10 @@
 
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message.");
-    if( psVectorStats(myStats, NULL, NULL, 0) != myStats ) {
+    if( psVectorStats(myStats, NULL, NULL, NULL, 0) != myStats ) {
         psError(PS_ERR_UNKNOWN,true,"psVectorStats did not return stats when input NULL");
         return 10;
     }
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message.");
-    psStats *myStats2 = psVectorStats(NULL, myVector, NULL, 0);
+    psStats *myStats2 = psVectorStats(NULL, myVector, NULL, NULL, 0);
     if ( myStats2 != NULL ) {
         psError(PS_ERR_UNKNOWN,true,"psVectorStats did not return NULL");
Index: /trunk/psLib/test/dataManip/tst_psStats01.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats01.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psStats01.c	(revision 2780)
@@ -61,5 +61,5 @@
                             "PS_STAT_MAX: no vector mask");
 
-    myStats = psVectorStats(myStats, myVector, NULL, 0);
+    myStats = psVectorStats(myStats, myVector, NULL, NULL, 0);
     max = myStats->max;
 
@@ -84,5 +84,5 @@
                             "PS_STAT_MAX: with vector mask");
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 1);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 1);
     max = myStats->max;
     printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
Index: /trunk/psLib/test/dataManip/tst_psStats02.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats02.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psStats02.c	(revision 2780)
@@ -59,5 +59,5 @@
                             "PS_STAT_MIN: no vector mask");
 
-    myStats = psVectorStats(myStats, myVector, NULL, 0);
+    myStats = psVectorStats(myStats, myVector, NULL, NULL, 0);
     min = myStats->min;
 
@@ -83,5 +83,5 @@
                             "PS_STAT_MIN: with vector mask");
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 1);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 1);
     min = myStats->min;
     printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
Index: /trunk/psLib/test/dataManip/tst_psStats03.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats03.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psStats03.c	(revision 2780)
@@ -53,5 +53,5 @@
                             "PS_STAT_SAMPLE_MEDIAN: no vector mask");
 
-    myStats = psVectorStats(myStats, myVector, NULL, 0);
+    myStats = psVectorStats(myStats, myVector, NULL, NULL, 0);
     median = myStats->sampleMedian;
 
@@ -78,5 +78,5 @@
                             "PS_STAT_SAMPLE_MEDIAN: with vector mask");
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 1);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 1);
     median = myStats->sampleMedian;
     printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
Index: /trunk/psLib/test/dataManip/tst_psStats06.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats06.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psStats06.c	(revision 2780)
@@ -62,5 +62,5 @@
                             "PS_STAT_SAMPLE_STDEV: no vector mask");
 
-    myStats = psVectorStats(myStats, myVector, NULL, 0);
+    myStats = psVectorStats(myStats, myVector, NULL, NULL, 0);
     stdev = myStats->sampleStdev;
 
@@ -86,5 +86,5 @@
                             "PS_STAT_SAMPLE_STDEV: with vector mask");
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 1);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 1);
     stdev = myStats->sampleStdev;
     printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
Index: /trunk/psLib/test/dataManip/tst_psStats07.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats07.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psStats07.c	(revision 2780)
@@ -72,5 +72,5 @@
                              "PS_STAT_ROBUST_STATS: robust mean: no vector mask" );
 
-    myStats = psVectorStats( myStats, myVector, NULL, 0 );
+    myStats = psVectorStats( myStats, myVector, NULL, NULL, 0 );
 
     printf( "The expected Mean was %.2f; the calculated Mean was %.2f\n",
@@ -312,5 +312,5 @@
 
     printf( "Calling psVectorStats() on a vector with elements masked.\n" );
-    myStats = psVectorStats( myStats, myVector, maskVector, 1 );
+    myStats = psVectorStats( myStats, myVector, NULL, maskVector, 1 );
     printf( "Called psVectorStats() on a vector with elements masked.\n" );
     printf( "The expected Mean was %.2f; the calculated Mean was %.2f\n",
Index: /trunk/psLib/test/dataManip/tst_psStats08.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats08.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psStats08.c	(revision 2780)
@@ -63,5 +63,5 @@
                             "PS_STAT_SAMPLE_LQ: no vector mask");
 
-    myStats = psVectorStats(myStats, myVector, NULL, 0);
+    myStats = psVectorStats(myStats, myVector, NULL, NULL, 0);
 
     printf("Called psVectorStats() on a vector with no elements masked.\n");
@@ -85,5 +85,5 @@
                             "PS_STAT_SAMPLE_UQ: no vector mask");
 
-    myStats = psVectorStats(myStats, myVector, NULL, 0);
+    myStats = psVectorStats(myStats, myVector, NULL, NULL, 0);
 
     printf("Called psVectorStats() on a vector with no elements masked.\n");
@@ -108,5 +108,5 @@
                             "PS_STAT_SAMPLE_LQ: with vector mask");
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 1);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 1);
 
     printf("Called psVectorStats() on a vector with elements masked.\n");
@@ -130,5 +130,5 @@
                             "PS_STAT_SAMPLE_UQ: with vector mask");
 
-    myStats = psVectorStats(myStats, myVector, maskVector, 1);
+    myStats = psVectorStats(myStats, myVector, NULL, maskVector, 1);
 
     printf("Called psVectorStats() on a vector with elements masked.\n");
Index: /trunk/psLib/test/dataManip/tst_psStats09.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats09.c	(revision 2779)
+++ /trunk/psLib/test/dataManip/tst_psStats09.c	(revision 2780)
@@ -68,5 +68,5 @@
                             "PS_STAT_CLIPPED_MEAN: no vector mask");
 
-    myStats = psVectorStats(myStats, myGaussData, NULL, 0);
+    myStats = psVectorStats(myStats, myGaussData, NULL, NULL, 0);
 
     printf("Called psVectorStats() on a vector with no elements masked.\n");
@@ -99,5 +99,5 @@
                             "PS_STAT_CLIPPED_MEAN: vector mask");
 
-    myStats = psVectorStats(myStats, myGaussData, maskVector, 1);
+    myStats = psVectorStats(myStats, myGaussData, NULL, maskVector, 1);
 
     printf("Called psVectorStats() on a vector with elements masked.\n");
Index: /trunk/psLib/test/dataManip/verified/tst_psRandom.stdout
===================================================================
--- /trunk/psLib/test/dataManip/verified/tst_psRandom.stdout	(revision 2780)
+++ /trunk/psLib/test/dataManip/verified/tst_psRandom.stdout	(revision 2780)
@@ -0,0 +1,69 @@
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psRandom.c                                             *
+*            TestPoint: psRandom functions{psRandomAlloc()}                        *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psRandom functions{psRandomAlloc()} | tst_psRandom.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psRandom.c                                             *
+*            TestPoint: psRandom functions{psRandomAlloc() and psRandomUniform()}  *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+Mean is 0.498160
+Standard deviation is 0.287816
+
+---> TESTPOINT PASSED (psRandom functions{psRandomAlloc() and psRandomUniform()} | tst_psRandom.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psRandom.c                                             *
+*            TestPoint: psRandom functions{psRandomAlloc() and psRandomGaussian()} *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+Mean is -0.007538
+Standard deviation is 0.992094
+
+---> TESTPOINT PASSED (psRandom functions{psRandomAlloc() and psRandomGaussian()} | tst_psRandom.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psRandom.c                                             *
+*            TestPoint: psRandom functions{psRandomAlloc() and psRandomPoisson()}  *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+Mean is 14.978700
+Standard deviation is 3.858498
+
+---> TESTPOINT PASSED (psRandom functions{psRandomAlloc() and psRandomPoisson()} | tst_psRandom.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psRandom.c                                             *
+*            TestPoint: psRandom functions{psRandomAlloc(), psRandomReset(), and psRandomUniform()} *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psRandom functions{psRandomAlloc(), psRandomReset(), and psRandomUniform()} | tst_psRandom.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psRandom.c                                             *
+*            TestPoint: psRandom functions{psRandomAlloc(), psRandomReset(), and psRandomGaussian()} *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psRandom functions{psRandomAlloc(), psRandomReset(), and psRandomGaussian()} | tst_psRandom.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psRandom.c                                             *
+*            TestPoint: psRandom functions{psRandomAlloc(), psRandomReset(), and psRandomPoisson()} *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psRandom functions{psRandomAlloc(), psRandomReset(), and psRandomPoisson()} | tst_psRandom.c)
+
