Skip to content

Instantly share code, notes, and snippets.

@MarwanDebbiche
Created October 15, 2020 12:06
Show Gist options
  • Save MarwanDebbiche/b02a7b8c5c40244948dc7c256d1aed3c to your computer and use it in GitHub Desktop.
Save MarwanDebbiche/b02a7b8c5c40244948dc7c256d1aed3c to your computer and use it in GitHub Desktop.
import math
import numpy as np
import pandas as pd
from tsgen.time_serie import TimeSerie
def affine(start, end, freq, start_y, end_y):
index = pd.date_range(start=start, end=end, freq=freq)
return TimeSerie(index=index, y=np.linspace(start_y, end_y, len(index)))
def constant(start, end, freq, value):
return affine(start, end, freq, value, value)
def cosine(start, end, freq, amp=1, n_periods=1):
index = pd.date_range(start=start, end=end, freq=freq)
return TimeSerie(
index=index,
y=amp
* np.cos(np.linspace(0, 2 * math.pi * n_periods, num=len(index))),
)
def sine(start, end, freq, n_periods=1):
index = pd.date_range(start=start, end=end, freq=freq)
return TimeSerie(
index=index,
y=np.sin(np.linspace(0, 2 * math.pi * n_periods, num=len(index))),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment