Created
December 23, 2023 05:40
-
-
Save galenseilis/da3a4ecd535444b90744354127e1de3b to your computer and use it in GitHub Desktop.
WeekDayConstrainedDist for HCiw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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