If I have a sensor in the road, that measures the date+time of every vehicle that passes and it's current speed. These sampling points are more frequent in rush hour and far less frequent during the night. Traffic lights might also make cars pass more frequent one minute and far less another. Now, i need to calculate the mean or average number of cars that passed and their average speed for periods of 30 minutes. E.g. in rush hour from 16:30 to 17:00 and 17:00 to 17:30 etc. But what is the correct way to do this when displaying in a graph or chart? Lets take the 17:00 to 17:30 samples. Lets say we have 1152 samples. Do I just calculate the mean (add all speeds and divide by 1152). What time should I display for this mean value in the chart? Do I have to calculate the average time of the samples (add all the times and divide by 1152) and this is the time of the mean value? If I want to have the mean exactly at 17:00. Do I take values from 16:45 to 17:15 or do I need to find an equal amount of samples before and after 17:00 or what is the correct way to calculate the mean for a specific point in time? I hope you can understand my issue (there are probably a correct name or term for this) and that someone can direct me to some papers about these type of calculations or just give me an easy to understand answer here (even though I suspect there is no easy way to do this).

  • $\begingroup$ What I would do is to not touch the passing times, but instead just put them into different "boxes". One such box can be the time between 16:30 and 17:00. You can try different methods of choosing these boxes, for example half an hour resolution or one hour resolution. And when graphing the results, write the interval you used in the x-axis below the appropriate value. $\endgroup$ – Matti P. Aug 24 '18 at 7:54
  • $\begingroup$ And within a box, just calculate the average speed in that box. I think this approach is the most simple and it should work. $\endgroup$ – Matti P. Aug 24 '18 at 7:55
  • $\begingroup$ If I want a box with the 17:00 mark displayed on the chart, I should take values from 16:30 to 17:30 and calculate the average and display. What if 80% of the samles in the time span from 16:30 to 17:30 is at the 17:00-17:30 span, then the average at 17:00 is kind of wrong. I guess there is no way to do this 100% right. $\endgroup$ – nivs1978 Aug 24 '18 at 8:40
  • $\begingroup$ You are correct that taking averages and putting stuff to boxes indeed leaves out a lot of information. What is the context for this task? I guess you can just not worry about this too much and use the simplest approach. $\endgroup$ – Matti P. Aug 24 '18 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.