Skip to content

Instantly share code, notes, and snippets.

@galenseilis
Created December 23, 2023 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galenseilis/da3a4ecd535444b90744354127e1de3b to your computer and use it in GitHub Desktop.
Save galenseilis/da3a4ecd535444b90744354127e1de3b to your computer and use it in GitHub Desktop.
WeekDayConstrainedDist for HCiw
class WeekDayConstrainedDist(ciw.dists.Distribution):
def __init__(self, dist, offset=0, *args, **kwargs):
super().__init__(*args, **kwargs)
self.dist = dist
self.offset = offset
def sample(self, t=None, ind=None):
tau = (np.floor(t) - self.offset + 7) % 7
if tau < 5:
return self.dist.sample(t, ind)
elif tau == 5:
return 2
else:
return 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment