0
$\begingroup$

I'm want to calculate the average day and respective month that a specific event happens in a sample of countries. So for each country I have the date (one per year) of the particular event. Now my problem is that this event happens, for example, during the winter in some countries, while for other during summer. The variability from year to year can be some months, so for example in the year 2000 can happen at November, do not take place at 2001 but rather at 2002 in January. I first though: ok, lets calculate the number of days that have passed from the first day of the year, in case the date is before August, and the number of days that are still to come until the end of the year, for the case the date is after August (being these last ones negative numbers). This works for the countries where the event happens always in winter. But for those that happen in summer it doesn't. Because, for example, I can have an event at June, that averaged with an event that happens in September, will give an average of something like April (because of the negative values of the September event), instead of August. So, my question is: is there a simple and clever way to solve this problem? I must then code this.

$\endgroup$
0
$\begingroup$

This has come up many times on this site in the context of averaging angles. One response is here. About the best you can do is find a central date for each event and average the days from then. For a summer event, maybe the central date is August 1, and you count days to the closest of those. Maybe the central date has to vary by country.

$\endgroup$
  • $\begingroup$ Thanks! Averages angle was my 2nd idea but then how can I know which central value for the respective country? The problem is that I have to design the algorithm to be the most general possible. $\endgroup$ – Miguel Oct 31 '14 at 14:29
  • $\begingroup$ Either they are bunched in a country over a reasonably short span and you can take the middle, or they are spread throughout the year and you may as well give up (or take an arbitrary center date). You could search for the longest span where there never is an event. Maybe you find no events between March 1 and August 1. Then the center is about December 1. $\endgroup$ – Ross Millikan Oct 31 '14 at 14:33
  • $\begingroup$ Yes, they "are bunched in a country over a reasonably short span. And the question is exacly that. How do I find the middle point? $\endgroup$ – Miguel Oct 31 '14 at 15:39
  • $\begingroup$ Then you can just take the center of that span as your reference point and count days ahead and behind. You will avoid any loop around problems that way. I would take each event, count the days to the next occurrence (regardless of year), find the biggest gap, then make the reference day 182 days from the center of the biggest gap, and average the offsets. The problem comes if there are two "biggest gaps" that are about the same size. It may not be obvious what to do then. $\endgroup$ – Ross Millikan Oct 31 '14 at 16:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.