[seconds] * [block reward] * [hash rate] / (difficulty * 4295032833) = Coins
where seconds is the time period you want to calculate for (86400 for a day, 2592000 for a month, etc.)
What's that number - 4295032833? Network total hashrate?
4295032833? What?) Should be 2^32 = 4294967296
Difficulty should be an average from all the blocks in a specific time period.