jeudi 13 mai 2021

Using Python for Random Number Generation Based on Percent Chance

I have an appliance that operates in two states - on and off. Between a certain time period in a day (say 6 am to 8pm), it has 5% chance of being on and 95% chance of being off. Between the remaining time period (8pm to 6am), it has 75% chance of being on. How do I use a random number generator in Python to generate a time series of on/off states for a week? The output should be an array of 1s and 0s.




Aucun commentaire:

Enregistrer un commentaire