Statistics library problems

I'm trying to use the Statistics.h library that Rob Tillaart developed but I'm running into a problem. I have attached my code here.

#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
#include "Statistics.h"

#define ECHO_TO_SERIAL   1 // echo data to serial port
#define WAIT_TO_START    1 // Wait for serial input in setup()

RTC_DS1307 RTC; // define the Real Time Clock object

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;

// the logging file
File logfile;

void error(char *str)
{
  Serial.print("error: ");
  Serial.println(str);
  while(1);
}

//int IRSense1 = 4;
//int IRSense2 = 4;
//int IRSense3 = 6;
//int IR1 = 0;
//int IR2 = 0;
//int IR3 = 0;
int CdSPin = 0;
int CdSReading;
Statistics myStats;
int counter = 0;
int currentState = 0;
int previousState = 0;

void setup(void)
{
  //pinMode(IRSense1, INPUT);
  //pinMode(IRSense2, INPUT);
  //pinMode(IRSense3, INPUT);
  Serial.begin(9600);
  Serial.println();
  myStats.clear();

#if WAIT_TO_START
  Serial.println("Type any character and press Enter to start");
  while (!Serial.available());
#endif //WAIT_TO_START

  // initialize the SD card
  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    error("Card failed, or not present");
  }
  Serial.println("card initialized.");

  // create a new file
  char filename[] = "Logger00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE); 
      break;  // leave the loop!
    }
  }

  if (! logfile) {
    error("couldnt create file");
  }

  Serial.print("Logging to: ");
  Serial.println(filename);

  // connect to RTC
  Wire.begin();  
  if (!RTC.begin()) {
    logfile.println("RTC failed");
#if ECHO_TO_SERIAL
    Serial.println("RTC failed");
#endif  //ECHO_TO_SERIAL
  }

  logfile.println("datetime, count");    
#if ECHO_TO_SERIAL
  Serial.println("datetime, count");
#endif //ECHO_TO_SERIAL

}
void loop(void)
{
  DateTime now;
  //IR1 = digitalRead(IRSense1);
  //IR2 = digitalRead(IRSense2);
  //IR3 = digitalRead(IRSense3);
  analogRead(CdSPin);
  delay(10);
  CdSReading = analogRead(CdSPin);
  myStats.add(CdSReading);
  Serial.println("Count");
  Serial.println(myStats.count());
  Serial.println("Average");
  Serial.println(myStats.average(),4);
  Serial.println("Std Deviation");
  Serial.println(myStats.pop_stdev(),4);
  //  if (CdSReading <= 940)
  //  {
  //    currentState = 1;
  //  }
  /*if (IR1 == HIGH)
   {
   currentState = 1;
   }
   if (IR2 == HIGH)
   {
   currentState = 1;
   }
  /*
   else if (IR3 == HIGH)
   {
   currentState = 1;
   }
   */
  //  else
  //  {
  //    currentState = 0;
  //  }
  if (currentState != previousState)
  {
    if(currentState == 1)
    {
      counter = counter + 1;
      // fetch the time
      now = RTC.now();
      // log time
      logfile.print('"');
      logfile.print(now.year(), DEC);
      logfile.print("/");
      logfile.print(now.month(), DEC);
      logfile.print("/");
      logfile.print(now.day(), DEC);
      logfile.print(" ");
      logfile.print(now.hour(), DEC);
      logfile.print(":");
      logfile.print(now.minute(), DEC);
      logfile.print(":");
      logfile.print(now.second(), DEC);
      logfile.print('"');
      logfile.print(",");
      logfile.println(counter);
#if ECHO_TO_SERIAL
      Serial.print('"');
      Serial.print(now.year(), DEC);
      Serial.print("/");
      Serial.print(now.month(), DEC);
      Serial.print("/");
      Serial.print(now.day(), DEC);
      Serial.print(" ");
      Serial.print(now.hour(), DEC);
      Serial.print(":");
      Serial.print(now.minute(), DEC);
      Serial.print(":");
      Serial.print(now.second(), DEC);
      Serial.print('"');
      Serial.print(",");
      //Serial.println(counter);
      Serial.println(CdSReading);
#endif
    }
  }
  previousState = currentState;
  logfile.flush();
  delay(1000);
}

These are the errors:
IR_Pulse_Counter_SDcomm:32: error: 'Statistics' does not name a type
IR_Pulse_Counter_SDcomm.ino: In function 'void setup()':
IR_Pulse_Counter_SDcomm:44: error: 'myStats' was not declared in this scope
IR_Pulse_Counter_SDcomm.ino: In function 'void loop()':
IR_Pulse_Counter_SDcomm:106: error: 'myStats' was not declared in this scope

To use the library, I copied the code for the .h and .cpp files into notepad, saved them as Statistics.h and Statistics.copp in C:\Program Files (x86)\Arduino\libraries\Statistics. Put in the #include, declared Statistics myStats, etc. Is there something that I'm missing?

Usually libraries are put in the folder libraries that is in your sketchbook folder, not the system library folder. After any changes you have to restart the Arduino IDE for it to scan for new files. (Yes, strange and stupid, but thats the way it is)

Also I have had bad experince with using notepad as windows and the Arduino stuff use differnet linebreaks (window vs unix style).

Lastly look at all the diagnostic output, possibly enable verbose output. It may say that it cant find the file "Statistics.h".

Use

#include <Statistics.h>

not

#include "Statistics.h"

Unless the .h file is in your sketch rather being a library

Msquare, I tried moving the Statistics folder to the libraries folder in C:\Users\loneill\Documents\Arduino\libraries\Statistics but still got the same errors. Even deleting the library from my computer, redoing the manual installation of the .h and .cpp into the Statistics folder in C:\Users\loneill\Documents\Arduino\libraries\Statistics, the same errors come up.

I'm not familiar with doing a diagnostic output by enabling verbose output. Searching the Playground didn't give me much useful info. Can you provide some info or guidance?

MarkT, I tried using #include <Statistics.h> but still had the same errors come up.

Thanks!

All my libraries are in the arduino libraries folder, not the sketchbook folder. Apparently you can use either. But yeah, maybe thats what the difference between #include "Lib.h" and #include <Lib.h> is all about, I have never understood it.

The Arduino's way of implementing the search path of "file" and includes baffels me, too, sometimes. Also even on Windows it sometimes seems case sensitive. (And that may be you problem)

Verbose output on the newer IDE is a tickbox option in preferences. This affects the amount of information in the (black) bottom window during compilaion and/or uploading

All my libraries are in the arduino libraries folder, not the sketchbook folder. Apparently you can use either.

You are going to be in a world of hurt when 1.0.6 is released. I will be fine, since all my libraries are where they belong.

You are going to be in a world of hurt when 1.0.6 is released. I will be fine, since all my libraries are where they belong.
[/quote]

I believe I'm saving all my libraries in the correct spot as other programs not using the Statistics library run fine. Just curious, do you save them in My Documents or Program Files? I tried copying a couple libraries over to C:\Users\loneill\Documents\Arduino\libraries from C:\Program Files (x86)\Arduino\libraries. It just makes a replicate under the "Contributed Libraries."

The question is, and correct me if I'm wrong, library folders should be stored in the sketchbook location (which is found in the preferences menu)?

PaulS, can you explain what will be different in the 1.0.6 release or why we will be in a world of hurt? Any and all constructive criticism is welcomed and appreciated.

PaulS, can you explain what will be different in the 1.0.6 release or why we will be in a world of hurt? Any and all constructive criticism is welcomed and appreciated.

I have no idea if, or when, there will be a 1.0.6 version. But, when it is released, it will NOT access libraries in the xxx\arduino_1.0.5\libraries folder. It will access user-downloaded libraries in the xxx\Arduino\libraries folder.

Prior to the 1.0 releases, users downloaded libraries into the arduino_00xx folder. A new version of the IDE came along, and you had to download the libraries all over again. What a pain, if you had a hundred libraries. Now, a new version of the IDE does not require re-downloading (or moving or copying) all those libraries.

When the angle brackets are used (<header.h>), the compiler looks in the default header file directory as set up for the compiler (i.e., on path). When double quotes are used ("header.h"), the compiler first looks in the current working directory for the header file. If that search fails, most setups then fall back to the default header file directory.

YMMV - I tested all combos (well, all the ones I could think of) This the 1.0.5 version on Win-XP

Yes, you have to restart the IDE to see a new directory, but not to see new file content.

It does not matter if the library files are in folder of that name - the folder can be anything (as long as it is sub-folder in Arduino\Libraries)

Names are case sensitive.

If a file is in both locations it depends on the ordering of the includes which file wins. The "" or <> do not matter.

If a file is missing the "" gives a message.