All hash rates are a calculation based on shares submitted, they are not based on a count of hashes a miner has done.
Your miner doesn't know how many hashes it's done either, it also just does a calculation based on the Difficulty of the nonces it generates.
That's a perfect explanation, although I think one needs to really understand the difference between hashes and shares, the simplest way to think of it is that shares are essentially 'accepted' hashes, you could have a centillion number of hashes and 0 shares.
The equation is rather simple; the example posted by NFW is missing the ^ between 2 and 32, probably
Estimated Hashrate= Shares Submitted×Share Difficulty×2^32 / Time
Using the some numbers from NFW post you have
Estimated Hashrate= 18×8190×2^32 / 60
=18x 8190x4,294,967,296 / 60
= 633,164,078,776,320 /60
= 10,552,734,646,272 hashes per second
You can convert it to terahash by dividing it by 1 trillion (12 zeros), and you get 10.55 THs
This is the reason why it takes time for your reported hashrate to become accurate, and it's how the pool adjusts the share difficulty to avoid two things
1- you sumbiting a huge number of shares per x unit of time.
2- you are not sumbting any shares for a very long period.
Obviously, the targeted number of shares per x unit is going to differ from one pool to another, you can figure this out based on the share difficulty the pool sets vs your estimated hashrate.