in simulate, you find:
prob_joint = normalize(prob_user * prob_usage)
In the Matlab version I have coded this a bit differently. In case there is a prob_usage that is not only 1's (e.g. for the kitchen tap), this pdf is prevailing. Only when the users are not present, then a correction is made. This means that prob_user is first converted to 0 (not present) and 1 (present), but without the information on peak, night, away included.
Of course when prob_usage is only 1's, then prob_user is prevailing, and the information on peak, night and away is used.
This problem can be solved by appling bool calculation.
Besides, the joint probability can be calculated outside the 'for' cycle and normalized in the cycle(reduce the number of operations).
in simulate, you find: prob_joint = normalize(prob_user * prob_usage)
In the Matlab version I have coded this a bit differently. In case there is a prob_usage that is not only 1's (e.g. for the kitchen tap), this pdf is prevailing. Only when the users are not present, then a correction is made. This means that prob_user is first converted to 0 (not present) and 1 (present), but without the information on peak, night, away included. Of course when prob_usage is only 1's, then prob_user is prevailing, and the information on peak, night and away is used.