Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
Compute statistics for data entered in rreal-time. More...
#include <assert.h>
#include <math.h>
#include <stdio.h>
Functions | |
void | stats_computer1 (float x, float *mean, float *variance, float *std) |
continuous mean and variance computance using first value as an approximation for the mean. | |
void | stats_computer2 (float x, float *mean, float *variance, float *std) |
continuous mean and variance computance using Welford's algorithm (very accurate) | |
void | test_function (const float *test_data, const int number_of_samples) |
Test the algorithm implementation. | |
int | main (int argc, char **argv) |
Main function. | |
Compute statistics for data entered in rreal-time.
This algorithm is really beneficial to compute statistics on data read in realtime. For example, devices reading biometrics data. The algorithm is simple enough to be easily implemented in an embedded system.
int main | ( | int | argc, |
char ** | argv | ||
) |
Main function.
void stats_computer1 | ( | float | x, |
float * | mean, | ||
float * | variance, | ||
float * | std | ||
) |
continuous mean and variance computance using first value as an approximation for the mean.
If the first number is much far form the mean, the algorithm becomes very inaccurate to compute variance and standard deviation.
[in] | x | new value added to data set |
[out] | mean | if not NULL, mean returns mean of data set |
[out] | variance | if not NULL, mean returns variance of data set |
[out] | std | if not NULL, mean returns standard deviation of data set |
void stats_computer2 | ( | float | x, |
float * | mean, | ||
float * | variance, | ||
float * | std | ||
) |
continuous mean and variance computance using Welford's algorithm (very accurate)
[in] | x | new value added to data set |
[out] | mean | if not NULL, mean returns mean of data set |
[out] | variance | if not NULL, mean returns variance of data set |
[out] | std | if not NULL, mean returns standard deviation of data set |
void test_function | ( | const float * | test_data, |
const int | number_of_samples | ||
) |
Test the algorithm implementation.
[in] | test_data | array of data to test the algorithms |
[in] | number_of_samples | number of samples of data |