Matthew's Portfolio
StatTracker Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ StatTracker()

StatTracker::StatTracker ( void  )

Initialize variables for future statistical calculations.

This constructor initializes any necessary varaibles for when the object of the class is instantiated.

Member Function Documentation

◆ add_data() [1/3]

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.

Parameters
new_floatThe new floating-point number to be added to the class.

◆ add_data() [2/3]

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.

Parameters
new_intThe new signed integer to be added to the class.

◆ add_data() [3/3]

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.

Parameters
new_uintThe new unsigned integer to be added to the class.

◆ average()

float StatTracker::average ( void  )

Computes an average of all data.

Returns
The average of all measurements that have been added to database.

◆ num_points()

uint32_t StatTracker::num_points ( void  )

Counts and returns the total number of data points added to the data set.

Returns
The number of measurements that have been added to database.

◆ std_dev()

float StatTracker::std_dev ( void  )

Computes a standard deviation of all data.

This standard deviation is given by the formula in the assignment.

Returns
The standard deviation of all measurements that have been added to database.

The documentation for this class was generated from the following files: