I need to calculate the birthdate of an ancestor based on a list of dates and ages he had, the problem is that I stink at circular maths and rotating stuff.
I have this dictionary in python: The left side are dates and the right side after ':' are ages
traces={
'2/2/1985':4,
'27/12/1988':7,
'25/12/1990':9,
'8/5/1994':13,
'6/7/1996':15,
'12/1/2001':20
}
What I more or less get to is: Converting all the dates to unitary years and resting the years:
1981.1698630136987 + a =birthdate
1982.0602739726028 + b =birthdate
1982.054794520548 + c =birthdate
1981.4328767123288 + d =birthdate
1981.5917808219178 + e =birthdate
1981.1150684931506 + f =birthdate
-1<{a,b,c,d,e,f}<1
It defeated me. Is there any solution for this?
Edit, the key of the problem always will be:
4 =floor( 1985.1698630136987 -birthdate)
7 =floor( 1989.0602739726028 -birthdate)
9 =floor( 1991.054794520548 -birthdate)
13 =floor( 1994.4328767123288 -birthdate)
15 =floor( 1996.5917808219178 -birthdate)
20 =floor( 2001.1150684931506 -birthdate)
(Edit: Whoops, fixed an off-by-one error.)
If you know that a person was $n$ years old at time $t$ (expressed in fractions of a year) then you know that they were born between $t - n - 1$ (maybe plus a day or so) and $t - n$ (maybe minus a day or so). So every pair $(n_i, t_i)$ of an age and a date gives you a lower bound and an upper bound on the birthdate. That means all you need to do to aggregate all the information you get from multiple pairs is to store two variables, the best lower bound so far $\ell$ and the best upper bound so far $u$, and update them whenever a new lower bound $\ell_i = t_i - n_i - 1$ or upper bound $u_i = t_i - n_i$ beats the previous old one. Formally the update rule is
$$\ell \to \text{max}(\ell, t_i - n_i - 1)$$ $$u \to \text{min}(u, t_i - n_i).$$
After going through all pairs $(n_i, t_i)$ you end up with a range $\ell \le t_{\text{birth}} \le u$ in which the birthdate can fall, and this is the best you can say given the data. If at any point this range is empty (that is, if you ever get $\ell > u$) then the data was contradictory; if it narrows down to within a day then that's great; and otherwise it's always at most a year in size.
(This is ignoring any subtleties of calendar math weirdness involving leap years and so forth, which hopefully is being taken care of by some kind of dedicated calendar math package.)