a
Dependencies: QEI2 chair_BNO055 PID Watchdog VL53L1X_Filter ros_lib_kinetic
Dependents: wheelchairControlSumer19 Version1-0
Statistics/statistics.cpp
- Committer:
- jvfausto
- Date:
- 2019-06-28
- Revision:
- 27:da718b990837
- Child:
- 28:6d6bd8ad04dc
File content as of revision 27:da718b990837:
#include "statistics.h" #include "mbed.h" statistics::statistics(int* Input, int dataLengthIn, int firstDataPoint){ data = Input; dataLength = dataLengthIn; } double statistics::mean(){ double sum; for(int i = 0; i < dataLength; ++i) { sum += data[i]; } double average = sum/dataLength; return average; } double statistics::stdev(){ float sum = 0.0, mean, standardDeviation = 0.0; int i; for(int i = 0; i < dataLength; ++i) { sum += data[i]; } mean = sum/dataLength; for(int i = 0; i < dataLength; ++i) standardDeviation += pow(data[i] - mean, 2); return sqrt(standardDeviation / dataLength); }