Class which is given measurements and computes some statistical parameters. More...
#include <stat-tracker.h>
Public Member Functions | |
StatTracker (void) | |
Initialize variables for future statistical calculations. More... | |
void | add_data (float new_float) |
Add a float-type number to the database. More... | |
void | add_data (int32_t new_int) |
Add a signed int-type number to the database. More... | |
void | add_data (uint32_t new_uint) |
Add an unsigned int-type number to the database. More... | |
uint32_t | num_points (void) |
Counts and returns the total number of data points added to the data set. More... | |
float | average (void) |
Computes an average of all data. More... | |
float | std_dev (void) |
Computes a standard deviation of all data. More... | |
void | clear (void) |
Clears all the arrays. | |
Protected Attributes | |
uint32_t | numPoints |
Number of individual data points added to the class StatTracker . | |
float | sum |
Total sum of all data types within the class StatTracker . | |
float | sumSquared |
Sum of squared added data within the class StatTracker . | |
float | Sx |
Standard deviation of data within the class StatTracker . | |
Class which is given measurements and computes some statistical parameters.
This class will add data to a database and can compute averages or standard deviations when called. It can also return the number of measurements in the database or can clear all numbers.
StatTracker::StatTracker | ( | void | ) |
Initialize variables for future statistical calculations.
This constructor initializes any necessary varaibles for when the object of the class is instantiated.
void StatTracker::add_data | ( | float | new_float | ) |
Add a float-type number to the database.
This float data will be added to the running sum and sumSquared variables. as well as increment the counter for the number of data points in total.
new_float | The new floating-point number to be added to the class. |
void StatTracker::add_data | ( | int32_t | new_int | ) |
Add a signed int-type number to the database.
This int data will be added to the running sum and sumSquared variables as well as increment the counter for the number of data points in total.
new_int | The new signed integer to be added to the class. |
void StatTracker::add_data | ( | uint32_t | new_uint | ) |
Add an unsigned int-type number to the database.
This uint data will be added to the running sum and sumSquared variables as well as increment the counter for the number of data points in total.
new_uint | The new unsigned integer to be added to the class. |
float StatTracker::average | ( | void | ) |
Computes an average of all data.
uint32_t StatTracker::num_points | ( | void | ) |
Counts and returns the total number of data points added to the data set.
float StatTracker::std_dev | ( | void | ) |
Computes a standard deviation of all data.
This standard deviation is given by the formula in the assignment.