Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

01.04.01 - Pressure Regression Stream Example Update #13

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Statistical Library <sup>V1</sup>
# Statistical Library <sup>V1.4</sup>

![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)

Library - 01.04.00
Build - 01.04.01

---

Expand Down
Binary file modified examples/.DS_Store
Binary file not shown.
72 changes: 72 additions & 0 deletions examples/Pressure_Regression/Pressure_Regression.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include <Statistical.h>
#include <Environment.h>

Statistical DataSet;

// Set Array
float Data[5][2];

void setup() {

// Start Serial
Serial.begin(115200);

// Set Presicion
DataSet.Linear_Regression_Presicion = 5;

// First Pressure Read
for (uint8_t i = 0; i < DataSet.Linear_Regression_Presicion + 5; i++) {

// Measure Pressure
float _Pressure = Sensor.Read_Analog_Pressure(2, 50);

// Calculate Time Stamp
float _Time = ((float)millis() / 1000) / 60;

// Learn Data
DataSet.Array_FILO(Data, 5, _Time, _Pressure);

// Calculate Regression
DataSet.Linear_Regression_Calculate(Data);

// Clear DataSet
DataSet.Linear_Regression_Data_Clear();

}


}

void loop() {

// Measure Pressure
float _Pressure = Sensor.Read_Analog_Pressure(2, 50);

// Calculate Time Stamp
float _Time = ((float)millis() / 1000) / 60;

// Learn Data
DataSet.Array_FILO(Data, 5, _Time, _Pressure);

// Calculate Regression
DataSet.Linear_Regression_Calculate(Data);

// Calculate Anomaly
float _Pressure_Anomaly = DataSet.Linear_Regression_Slope * 100;

// Print Anomaly
//if (_Pressure_Anomaly > 4) Serial.println("Basinc Artisi");
//if (_Pressure_Anomaly < -4) Serial.println("Basinc Azalisi");

// Print Calculated Data
Serial.print("Pressure : "); Serial.print(_Pressure, 4); Serial.println(" Bar");
Serial.print("Slope : "); Serial.print(DataSet.Linear_Regression_Slope * 100, 4); Serial.println(" ");
Serial.println("----------------");

// Clear DataSet
DataSet.Linear_Regression_Data_Clear();

delay(2000);

}

11 changes: 9 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Statistical",
"version": "1.4.0",
"version": "1.4.1",
"keywords": "Statistical, Max, Min, Average, Regression, Data, Sensor, Slope, Offset",
"description": "Function calculates statistical parameters of data stream and array",
"authors":
Expand Down Expand Up @@ -31,12 +31,19 @@
]
},
{
"name": "Stream",
"name": "Regression",
"base": "examples/Regression/",
"files": [
"Regression.ino"
]
},
{
"name": "Pressure Regression Stream",
"base": "examples/Pressure_Regression/",
"files": [
"Pressure_Regression.ino"
]
},
{
"name": "Stream",
"base": "examples/Stream/",
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.0
version=1.4.1
author=Gunce Akkoyun <akkoyun@me.com>
maintainer=Gunce Akkoyun <akkoyun@me.com>
sentence=Statistic, Sum, Max, Min, Sq_Sum, Aritmetic Average, Geometric Average, RMS Average, Ext RMS Average, Bubble Sort, Median, Standart Deviation, Standart Deviation Error, Coefficient Factor, Average, Stream, Regression, Slope, Data, Analyse
Expand Down
2 changes: 1 addition & 1 deletion src/Statistical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Statistical::Linear_Regression_Calculate(float _Data[][2]) {
for (uint16_t i = 0; i < Linear_Regression_Presicion; i++) {

// Print Array
Serial.print(_Data[i][0]); Serial.print("-"); Serial.println(_Data[i][1]);
//Serial.print(_Data[i][0]); Serial.print("-"); Serial.println(_Data[i][1]);

// Push Data
Linear_Regression(_Data[i][0], _Data[i][1]);
Expand Down