Once an event happens, the probability distribution should be revised and renormalized again. Otherwise, for an end use with long time duration, events will overlap. For example, washing machine and shower.
Possible solution:
prob_joint = normalize(prob_user * prob_usage)
j = len(users)
freq = self.fctfrequency(numusers=len(users))
for in range(freq):
duration, intensity = self.fct_duration_intensity()
u = np.random.uniform()
start = np.argmin(np.abs(np.cumsum(prob_joint) - u))
end = start + duration
consumption[start:end, j, ind_enduse, pattern_num] = intensity
Once an event happens, the probability distribution should be revised and renormalized again. Otherwise, for an end use with long time duration, events will overlap. For example, washing machine and shower. Possible solution: prob_joint = normalize(prob_user * prob_usage) j = len(users) freq = self.fctfrequency(numusers=len(users)) for in range(freq): duration, intensity = self.fct_duration_intensity() u = np.random.uniform() start = np.argmin(np.abs(np.cumsum(prob_joint) - u)) end = start + duration consumption[start:end, j, ind_enduse, pattern_num] = intensity