Explain the math behind mining profitability calculators Can anyone explain the math behind the mining calculators like:

http://www.bitcoinx.com/profit/

I'm trying to build a Google spreadsheet that does the same thing.
Suppose your hashrate is H hashes per second.

There are 86400 seconds in a day, so every day you will generate 86400H hashes.

Every hash has roughly 1 in 2^32 chance to be a share, so you'll find 86400 H / 2^32 shares.

Every share has a chance of 1/D to be a block, so you'll find on average 86400 H / (2^32 D) blocks per day (currently D = 267731249).

Every block gives a reward of B, so you'll get on average (86400 H B) / (2^32 D) per day. (Currently B = 25 bitcoins).

Then you can take into account additional factors such as the exchange rate, power costs, difficulty going up over time (requires computing an integral), and so on.