Is the network hash rate just an estimate?
Yes, and a very tough one to make.
Actually, it's not that hard.
The wiki states somewhere (can't find the page now, of course) that the probability of a single hash calculation solving a block is
target
-------
2
256and the average number of hashes required to solve a block is its inverse:
2
256 -------
target
Let's call that last formula
A. On average, then, it takes
A hashes to solve a block. We know how long it takes to create a particular block (just take its creation timestamp and subtract the timestamp of the previous block from it). So the network hash rate is simply
A / timespan.
Of course, individual blocks will be highly variable due to the random nature of finding a solution (there were about 3 or 4 blocks recently that were created within 5 minutes; the block before that series took 20 minutes, as did the block after). To get a more accurate estimate, you'd want to take the time over 50 or 100 blocks. The formula is:
2
256 *
n-----------------------
target * (ts
N - ts
N-n)
where
n is the number of blocks you're sampling
ts
x is the timestamp of block number
xN is the latest block number (or whatever block number you want to end your sample range with)
and target is currently 0xCBBD000000000000000000000000000000000000000000000000