Skip to content

Instantly share code, notes, and snippets.

@andrhua
Last active January 5, 2019 21:28
Show Gist options
  • Save andrhua/5725715611eb204b6aab31be902bb237 to your computer and use it in GitHub Desktop.
Save andrhua/5725715611eb204b6aab31be902bb237 to your computer and use it in GitHub Desktop.
breakup date generator
import datetime
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline
if __name__ == '__main__':
# days elapsed from meeting to first copulation
xi = np.array([2*7, 2*30])
# days elapsed from meeting to breakup
yi = np.array([3*7, 6*30])
s = InterpolatedUnivariateSpline(xi, yi, k=xi.shape[0] - 1)
meeting_date = datetime.datetime(year=2015, month=12, day=2)
tolerance_period = s(3*365)
breakup_date = meeting_date + datetime.timedelta(days=int(tolerance_period))
print(breakup_date)
# 2026-03-16 00:00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment