Hi Scott, Assuming your $t is always increasing (you can qsort() it if it's not), you can assemble a vector of delta-t's, and if you're only interested in integer offsets, use the hist function to generate a histogram of sorts:
$dt = $t(1:-1) - $t(0:-2); ($interval,$number) = hist($dt,$dt->min-0.5,$dt->max+0.5,1); p $interval,$number; p $number->where($interval==50); Now you have one piddle that contains a list of the integer offsets, and another piddle that tells you the frequency. If you have non-integer times, then that will require some more thought as to how close two differences can be and be considered the same. I've also discovered that Maggie's PDL::Stats (available from CPAN) might have things that help with the time-series analysis you seem to be doing (see the PDL::Stats::TS module). For example, I recently had to take a moving average of a time series of data, then compute the point-to-point differences of that moving average, and it was as simple as: use PDL::Stats; $data->filter_ma(3)->diff; best, Derek On May 4, 2012, at 4:17 PM, Scott Penrose wrote: > Good morning > > I have a piddle with time stems, e.g. > > print $t; > [ 100, 150, 200, 249, 300 ]; > > The data is really long and obviously the example above is made up. > > Anyway I want to calculate the number between and calculate, so from the data > above I would have > > 50 = 2 > 49 = 1 > 51 = 1 > > The main reason I am doing this is to make sure that my measurements are on > the window (in this case 50 ms) and how many are not. > > Currently I just did it by hand, keeping the last value and iterating through > all the data in a loop. But it didn't feel very PDL way. What is the better > way? > > Ta > > Scott > > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
