You can use random numbers to determine a percentage chance of something happening.
Whenever the character thinks about going to bed…
There’s a 10% chance the character will sleep between 9 and 10 o’clock.
A 30% chance he will sleep between 10 and 11 o’clock
A 50% chance he will sleep between 11and 12 o’clock
And a 70 % chance he will sleep between 12 and 1 o’clock
You could also vary the amount of times the character thinks about going to bed. He’s more likely to think about sleep at midnight than he is at 9 o’clock. Depending on how realistic you want to be you could factor in various other possibilities - what time did the character go to bed the night before, how healthy is the character, what is his job the next day, etc.
Probably just stating the obvious, but It’s all about storing variables to represent various possibilities then rolling the dice to see what happens.
I’m sure I’ve seen AI tutorials pass though these boards, so you should be able to find some if you do a search.
EDIT:
I'm sure you'll find something here
http://www.thegamecreators.com/?m=codebase_list