MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / calc_stddev

Function calc_stddev

src/data_handler/data_handler.cpp:1099–1119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1097}
1098
1099int calc_stddev (double *data, int start_pos, int end_pos, double *output)
1100{
1101 if ((data == NULL) || (output == NULL) || (end_pos - start_pos < 2))
1102 {
1103 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
1104 }
1105 double mean = 0;
1106 for (int i = start_pos; i < end_pos; i++)
1107 {
1108 mean += data[i];
1109 }
1110 mean /= (end_pos - start_pos);
1111 double stddev = 0;
1112 for (int i = start_pos; i < end_pos; i++)
1113 {
1114 stddev += (data[i] - mean) * (data[i] - mean);
1115 }
1116 stddev /= (end_pos - start_pos);
1117 *output = sqrt (stddev);
1118 return (int)BrainFlowExitCodes::STATUS_OK;
1119}
1120
1121int get_num_elements_in_file (const char *file_name, int *num_elements)
1122{

Callers 1

calc_stddevMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected