 
 void loop() {
 //  int start_time = millis();
+double average = 0;
   for (int i = 0; i < numberOfReadings; i++) {
-    double sample_reading = reading();
-      myStats.add(sample_reading);
-//    Code takes ~245 ms to run (100 readings per output reading). 
+    average += reading()/numberOfReadings;
+//    Code takes ~243 ms to run (100 readings per output reading). 
 //    When delay = 0
       delay(0);
   }
-  
-  averagedOutput = myStats.average();
-  Serial.println(averagedOutput,2);
+//  Serial.println("Average: ");
+  Serial.println(average);
 //  int finish_time = millis();
 //  int difference = finish_time - start_time;
+//  Serial.println("Difference: ");
 //  Serial.println(difference);
   
 }

#include <Statistic.h>
Statistic myStats;
int sourceSensePin = A0;    // select the input pin for the potentiometer
int drainSensePin = A1;
double sourceSense = 0;
double drainSense = 0;
double sensor = 0;
int numberOfReadings = 400; // change this as required
unsigned int ADCValue;
double Vcc;
long result;
double averagedOutput;


long readVcc() {
  // Read 1.1V reference against AVcc

  drainSense = (drainSense / 1024.0) * Vcc;

  sensor = sourceSense - drainSense;
  return sensor;
}

//double average(double * array1, int len) {
//  for (int i = 0; i < len; i++) {
//      sum += array1[i];
//    }
//  return ((double) sum) / len;
//  }

void setup() { 
  Serial.begin(9600);
