Analysing data

  • I've got a little problem here, mostly because I'm not familiar with numeric mathematics.

    I've gathered some data from light sensors, which are placed next to a pendulum. Everytime the pendulum makes a swing, the light sensor has a drop in voltage. I need to find out where those peaks are, in order to determine the time each 'swing' takes.

    So, I've got a set of data, key: time, value: voltage, which follows this pattern:


    So I want to find the lowest point for each interval. I've messed around with the first and second numeric derivative's, but those lost a lot of precision. Any idea's?

  • Hello...


    Use the 1st Derivate, and then look in the original data to fing the Value you are looking for...  There should be a change from - to + when looking for the "lows" (Assuming "Derivate means Ableitung")


  • I tried that, however, I have over 50 points each second. Also, there are minor variations on seemingly straight places. Thinking about it, I might just add a threshold, but that would still leave me to figure out the exact spot.

  • Is your exercise to write a program that does this or are you just interested in the data? If you just need those data values can't you just look at the data and find the lowest points by inspection?


  • We're talking about quite a lot of data here, say 30 sets of 90 * 60 points, and I'm not interested in doing it manually. I'd rather have a program which handles each set in the same way. Note that the voltages are different for certain censors, so I can't use predefined values or thresholds. To answer your question, it's about the data.

  • To reduce the number of false maximums/minimums you can perform a running average, or even just a simple block average, over the data. Since the peaks you are interested in are large compared to any noise, you can probably get away with averaging over a relatively large interval. Then, just run a derivative over the averaged data and any 0 crossings will be your peaks (well half of them will be). You can also just look for local minimums in the averaged data over a specific interval, though this requires knowing the rough size and distance between peaks.


  • I think the easy dirty way if you're willing to enter a couple thresholds would be to find all the minima in the data below a threshold. Than for all the minima consolidate all minima within a certain time of eachoter  (say .2 for the data you posted) to one minima.

    Assuming you're trying to find the period of your pendulum I would suggest you use a discrete fourier transform. If you have access to a tool like matlab this will be easy to do. Squaring what you get back from a fast fourier transform gives you the power spectrum which will show you the frequency of your data as a giant spike. It's worth looking into.

  • It's been awhile since I had Electronics, but wouldn't you want to run your data through a low pass filter and then run your derivative analysis against the the filtered data?  I seem to remember Fast Fourier Transforms being used after the fact for filtering if your not using an actual filter in the circuit.


  • If the signal is known to be periodic and you want to find the period, use an FFT and look for the highest significance spike.

    If you want to find the locations of all the important minima, smooth the data (to avoid noise giving you lots of false positives) and then check for where the first derivative changes sign. 

  • Thanks a lot guys, I got it working perfectly now.

Log in to reply

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.