If not the precise algorithm (as it may be calculated in a complex manner) a way to roughly estimate would be helpful.
Yes actually I'm quite curious as well, does it take into consideration of the time taken for the round or does it not. Cuz if it doesn't then it'll be possible that a huge enough miner/pool to drop his/it's mining right before the difficulty adjustment to keep it in check.