Skip to content

Commit

Permalink
Merge pull request #26 from akkoyun/01.04.14
Browse files Browse the repository at this point in the history
01.04.14 - Initial update
  • Loading branch information
akkoyun authored Mar 7, 2022
2 parents 75c3171 + 5509b64 commit 6d8f97b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 120 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![GitHub release (latest by date)](https://img.shields.io/github/v/release/akkoyun/Statistical) ![arduino-library-badge](https://www.ardu-badge.com/badge/Statistical.svg?) ![Visits Badge](https://badges.pufler.dev/visits/akkoyun/Statistical) ![GitHub stars](https://img.shields.io/github/stars/akkoyun/Statistical?style=flat&logo=github) ![Updated Badge](https://badges.pufler.dev/updated/akkoyun/Statistical) ![PlatformIO Registry](https://badges.registry.platformio.org/packages/akkoyun/library/Statistical.svg)
[![Check Arduino](https://github.com/akkoyun/Statistical/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/akkoyun/Statistical/actions/workflows/check-arduino.yml) [![Compile Examples](https://github.com/akkoyun/Statistical/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/akkoyun/Statistical/actions/workflows/compile-examples.yml) [![Spell Check](https://github.com/akkoyun/Statistical/actions/workflows/spell-check.yml/badge.svg)](https://github.com/akkoyun/Statistical/actions/workflows/spell-check.yml)

Build - 01.04.13
Build - 01.04.14

---

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Statistical",
"version": "1.4.13",
"version": "1.4.14",
"keywords": "Statistical, Max, Min, Average, Regression, Data, Sensor, Slope, Offset",
"description": "Function calculates statistical parameters of data stream and array",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Statistical
version=1.4.13
version=1.4.14
author=Gunce Akkoyun <[email protected]>
maintainer=Gunce Akkoyun <[email protected]>
sentence=Statistic, Sum, Max, Min, Sq_Sum, Arithmetic Average, Geometric Average, RMS Average, Ext RMS Average, Bubble Sort, Median, Standard Deviation, Standard Deviation Error, Coefficient Factor, Average, Stream, Regression, Slope, Data, Analyse
Expand Down
70 changes: 8 additions & 62 deletions src/Statistical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,87 +9,33 @@
#include "Statistical.h"

// Stream Statistics
float Statistical::Stream_Max(float _Data) {
void Statistical::Stream_Statistic(float _Data) {

// Increase Data Count Variable
Stream_Data_Count_Max++;
// Set Data Count (+1)
Data_Count++;

// Calculate Max Value
if (Stream_Maximum == 0) Stream_Maximum = _Data;
if (_Data > Stream_Maximum) Stream_Maximum = _Data;

// End Function
return(Stream_Maximum);

}
void Statistical::Stream_Clear_Max(void) {

// Celar Stream Variables
Stream_Data_Count_Max = 0;
Stream_Maximum = 0;

}
float Statistical::Stream_Min(float _Data) {

// Increase Data Count Variable
Stream_Data_Count_Min++;

// Calculate Min Value
if (Stream_Minimum == 0) Stream_Minimum = _Data;
if (_Data < Stream_Minimum) Stream_Minimum = _Data;

// End Function
return(Stream_Minimum);

}
void Statistical::Stream_Clear_Min(void) {

// Celar Stream Variables
Stream_Data_Count_Min = 0;
Stream_Minimum = 0;

}
float Statistical::Stream_Aritmetic_Average(float _Data) {

// Increase Data Count Variable
Stream_Data_Count_Avg++;

// Calculate Avg Value
if (Stream_Average == 0) Stream_Average = _Data;
Stream_Average = Stream_Average + ((_Data - Stream_Average) / Stream_Data_Count_Avg);

// End Function
return(Stream_Average);
Stream_Average = Stream_Average + ((_Data - Stream_Average) / Data_Count);

}
void Statistical::Stream_Clear_Aritmetic_Average(void) {
void Statistical::Data_Clear(void) {

// Celar Stream Variables
Stream_Data_Count_Avg = 0;
Stream_Average = 0;

}
void Statistical::Stream_Statistic(float _Data) {

// Calculate Maximum
Stream_Max(_Data);

// Calculate Minimum
Stream_Min(_Data);

// Calculate Average
Stream_Aritmetic_Average(_Data);

}
void Statistical::Stream_Clear(void) {
// Clear Data Count
Data_Count = 0;

// Celar Stream Variables
Stream_Data_Count_Max = 0;
Stream_Average = 0;
Stream_Maximum = 0;
Stream_Data_Count_Min = 0;
Stream_Minimum = 0;
Stream_Data_Count_Avg = 0;
Stream_Average = 0;

}

Expand Down
60 changes: 5 additions & 55 deletions src/Statistical.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ class Statistical {
// ************************************************************

// Stream Calculation Variables
uint16_t Stream_Data_Count_Max = 0;
float Stream_Maximum = 0;
uint16_t Stream_Data_Count_Min = 0;
float Stream_Minimum = 0;
uint16_t Stream_Data_Count_Avg = 0;
uint16_t Data_Count = 0;
float Stream_Average = 0;

float Stream_Minimum = 0;
float Stream_Maximum = 0;

// Linear Regression Definitions
uint16_t Linear_Regression_Data_Count = 0;
uint16_t Linear_Regression_Precision = 0;
Expand All @@ -40,56 +38,8 @@ class Statistical {
// Public Functions
// ************************************************************

/**
* @brief Calculate Stream Maximum Value
* @version 01.00.00
* @param _Data Data Variable
*/
float Stream_Max(float _Data);

/**
* @brief Calculate Stream Minimum Value
* @version 01.00.00
* @param _Data Data Variable
*/
float Stream_Min(float _Data);

/**
* @brief Calculate Stream Average Value
* @version 01.00.00
* @param _Data Data Variable
*/
float Stream_Aritmetic_Average(float _Data);

/**
* @brief Clear Stream Maximum Value
* @version 01.00.00
*/
void Stream_Clear_Max(void);

/**
* @brief Clear Stream Minimum Value
* @version 01.00.00
*/
void Stream_Clear_Min(void);

/**
* @brief Clear Stream Average Value
* @version 01.00.00
*/
void Stream_Clear_Aritmetic_Average(void);

/**
* @brief Calculate Min, Max, Avg Value
* @version 01.00.00
*/
void Stream_Statistic(float _Data);

/**
* @brief Clear Stream Values
* @version 01.00.00
*/
void Stream_Clear(void);
void Data_Clear(void);

/**
* @brief Calculate Linear Regression
Expand Down

0 comments on commit 6d8f97b

Please sign in to comment.