vendredi 3 avril 2015

Counting data points within limits, and applying buffer to isolated points [data analysis]

I am stuck trying to solve this problem:


I have a set of data points, that correspond to a set of time values. i.e. values =[1,2,3,4,5,6,7,8,4] times = [0.1,0.2,0.3,0.4]... and so on, it's a sample rate of 10hz.


I need to find the time spent between two limits. so for example if my limits are 3 and 5 inclusive then 3,4,5,4 are in my limits.


if I calculate the time as number of (points -1) /sample rate, or the start time and end time of the grouping, I will miss out the isolated data point (the second 4)


I have proposed to use an imaginary buffer of half the sample rate either side to model the isolated events.


but I am having trouble implementing this in code (python) I need a way of iterating through the points, counting the number of points, with a pairing to be able to perform (number of points-1)/ sample rate. and also how to pick up the singular points and apply the buffer value to the number of points.


I can't seem to find the right combination of if and while statements to do this.


Aucun commentaire:

Enregistrer un commentaire