Git Product home page Git Product logo

peakdetection's Introduction

Hi 👋, I'm Leandro César

Tech lead and Python backend developer at Cloudia. Control and Automation Engineer (UNIFEI).

Projects:


Linkedin Twitter Instagram Facebook dev.to

peakdetection's People

Contributors

chand1012 avatar leandcesar avatar semcneil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

peakdetection's Issues

Adding Noise to the Input Signal

I am detecting an input signal from a sensor and plan to perform real time peak detection on it. But for some reason the peak detection calculations induces a lot of noise in the input signal.
Do you have any solution to prevent this ??

PeakDetection::getStd() is it correct?

Hey there,
I am trying to use your library implementation of the PeakDetection algorithm and I have to make some modifications for my needs. When trying to understand the code I stumbled upon your implementation of the getStd() method.

As far as I understand the algorithm this should just collect the sum of squared differences between stored values and the average value and then divide it by the amount of values to get the average squared difference of the values to the mean.
The square root of this is then returned as the average difference of the signal to the mean.

Other peoples code looks like this, and is easily understandable for me:
https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data/54507140#54507140 and I can understand it really well...

float stddev(float data[], int len) {
    float the_mean = mean(data, len);
    float standardDeviation = 0.0;

    int i;
    for(i=0; i<len; ++i) {
        standardDeviation += pow(data[i] - the_mean, 2);
    }
    return sqrt(standardDeviation/len);
}

Your implementation goes like this:

double PeakDetection::getStd(int start, int len) {
  double x1 = getAvg(start, len); 
  double x2 = getPoint(start, len);
  double powx1 = x1 * x1;
  double std = x2 - powx1;
  if (std > -EPSILON && std < EPSILON)
    return 0.0;
  else
    return sqrt(x2 - powx1);
}

and I really dont understand it. What is this getPoint() method doing?

double PeakDetection::getPoint(int start, int len) {
  double xi = 0.0;
  for (int i = 0; i < len; ++i)
    xi += data[(start + i) % lag] * data[(start + i) % lag];
  return xi / len;
}

If i understand correctly it returns the average squared values of all collected values. I don't get why this is necessary. Can you help me to understand this?

thank you for any help on this,
paul

__ EDIT:
Sorry, I just recalculated it with some test data and I am surprised your function gave the right result. Seems like a mathematical trick I would like to understand...
This is some test scenario with caluclations as I assume them:

testdata = [ 1, 7, 4, 2]
avg -> 14/4 = 3,5
stdDeviation -> -2.5, 3,5, 0.5, -1,5 -> 6.25 + 12,25 + 0,25 + 2,25 = 5,25
root(5,25) => 2,29128784747792

Your code results in :
x1 = 3,5
x2 -> 1 + 49 + 16 + 4 -> 17,5
powx1 = 12,25
std -> 17,5 - 12,25 = 5,25
root(5,25) => 2,29128784747792

int = .5 ?

const int DEFAULT_INFLUENCE = 0.5;
const int DEFAULT_EPSILON = 0.01;

How does that work?

lag threshold influence values

I have a sinewave from mpu9250 sensor which I need to calculate the max of during live sensor readings. I'm trying to understand how lag threshold influence values work in your library and what i should set them to. is there any other sources? In example they are peakDetection.begin(48, 3, 0.6); and have no idea why.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.