This is a good summary with how it works. Of course, I believe some shenanigans get in the way of the legitimate process, like why certain days are cheaper, like clock work. Link