## Probability and light switch...

Hello guys, I hope you can help with this problem:
Lets say a light switch is monitored and its state recorded every hour, ie has the light been switched on at anytime in the last hour? yes/no.
This result is stored in a database with an hourly time reference.

I'm looking for a probability factor to deduce if the light should be on according to previous data.

The database is updated with the status of the light switch in the last hour. The new state is compared with data of the state
of the switch at the same time yesterday, the day before that and so on for the last 4 days.

for example:
In the same time frame, eg 3 to 4 o'clock, for the previous 4 days, the light switch had been switched on in only one time frame.
So the probability of the light switch being switched on in the newest result is 25 percent.

So far so good, I think.
Lets assume the light switch has not been switched on in the lastest update.
We wait another hour and receive another update. Again the light switch has not been switched on. Looking at previous data for
the same time frame, eg this time it's 4 to 5 o'clock, we see that over the previous 4 days at the same time the light switch had
been switched on, on two separate days. So for this time frame there is a 50 percent chance of the light being on. However we need to take into account the previous result, which had a 25 percent chance of being true ie the light being on but was in fact off.

This continues to the next hourly result and so on until the light is eventually switched on. Each time a probability factor is needed to deduce the probability of the light being on using previous data.

What calculation is needed to ascertain if the light should have been switched on in the latest time frame?

I hope I make myself clear.
many thanks
Andy