user580: Can we find an algorithm to compute the average price (as energy consumption) of 1 BTC being generated if we know: hash rate, difficulty, energy price?

user5: Meni Rosenfeld's formula is what you are you are looking for. It is not possible to calculate the production cost of one bitcoin because of these two variables:

E - the mining efficiency, measured in MHash/J. 
c - the cost of electricity, measured in $/KWh.

There is a broad range of hardware which is not limited to GPUs - some people are mining with FPGAs for example - so you can't easily calculate the mining efficiency. The same happens with the cost of electricity because there are different prices for each country, hour of the day, residential/industrial systems, etc. And there are other factors such as the temperature (which reduces cooling costs) and alternative electricity sources (some people could be using solar panels for example). 
That being said, you could grab the formula, find the average electricity price per country, estimate an average mining efficiency (maybe based on the hardware wiki list) and reach a number, but it would be very inaccurate.
I made a script with a few examples:
B = 50
D = 1500000
Cost: $0.536992840095   E = 2 c = 0.03
Cost: $2.14797136038    E = 2 c = 0.12
Cost: $3.75894988067    E = 2 c = 0.21
Cost: $0.894988066826   E = 1.2 c = 0.03
Cost: $3.5799522673     E = 1.2 c = 0.12
Cost: $6.26491646778    E = 1.2 c = 0.21
Cost: $3.5799522673     E = 0.3 c = 0.03
Cost: $14.3198090692    E = 0.3 c = 0.12
Cost: $25.0596658711    E = 0.3 c = 0.21

Cost: $0.171837708831   E = 25 c = 0.12

I chose 3 values for mining efficiency in Mhash/J: 2, 1.2 and 0.3 (the greater the better) and 3 values for electricity cost in USD: 0.03, 0.12, 0.21 (the smaller the better).
Some boards, such as the 5850, have higher efficiency but we have to consider the system as a whole so 2 is still a high value. The average price of electricity per country can be found here, but I am going to list a few examples:

High electricity price - Ireland, Italy, Japan 
Medium electricity price - US, France, Poland
Low electricity price - Mexico, Taiwan, Kazakhstan

Using GPUs, the value ranges from $0.5 to $25 so it's not a small interval. The last line corresponds to the price of one bitcoin produced by an FPGA with electricity cost at $0.12 per KW/h: $0.17.

user323: As Bitcoin mining is very heterogeneous (that is, a lot of people use a wide variety of hardware), figuring this out would be really hard without the use of polling (as in, asking people questions, not long polling). One would need to get some statistical data on what hardware people have, how much they spend on electricity, and how much hashpower they have, not to mention how much they mine each day. Having all that, we could average it out and calculate something.
If you want to check how much your coin costs you, check out my calculator: http://tpbitcalc.appspot.com/ .

user575: The parameters you need to calculate this are:
E - the mining efficiency, measured in MHash/J. Data on this for various hardware is available in Mining hardware comparison (though this take into account only the card's power and not of the system it is in). Or you can calculate it for a given system by dividing the total hashrate (in MHash/s) by the power consumed (in W).
c - the cost of electricity, measured in $/KWh.
B - the bitcoin reward per block.
D - the difficulty.
The cost to generate 1 BTC is:
c*D/(838*B*E)
For example, if E=2, c=0.1, B=50 and D=1,500,000, this is
0.1*1500000/(838*50*2) = $1.79
The 838 "magic number" comes from the various unit conversion factors - 2^32 hashes per difficulty-1 hash, 3,600,000 Joules per Kilowatt-hour, 1,000,000 Hashes per MHash.

580: <p>Can we find an algorithm to compute the average price (as energy consumption) of 1 BTC being generated if we know: hash rate, difficulty, energy price?</p>
 5: <p><a href="https://bitcoin.stackexchange.com/questions/1606/world-wide-price-for-generating-1btc/1609#1609">Meni Rosenfeld's formula</a> is what you are you are looking for. It is not possible to calculate the production cost of one bitcoin because of these two variables:</p>

<blockquote>
  <p>E - the mining efficiency, measured in MHash/J. </p>
  
  <p>c - the cost of electricity, measured in $/KWh.</p>
</blockquote>

<p>There is a broad range of hardware which is not limited to GPUs - some people are mining with FPGAs for example - so you can't easily calculate the mining efficiency. The same happens with the cost of electricity because there are different prices for each country, hour of the day, residential/industrial systems, etc. And there are other factors such as the temperature (which reduces cooling costs) and alternative electricity sources (some people could be using solar panels for example). </p>

<p>That being said, you could grab the formula, find the <a href="http://www.theoildrum.com/node/7215" rel="nofollow noreferrer">average electricity price per country</a>, estimate an average mining efficiency (maybe based on the <a href="https://en.bitcoin.it/wiki/Mining_hardware_comparison" rel="nofollow noreferrer">hardware wiki list</a>) and reach a number, but it would be very inaccurate.</p>

<p>I made a script with a few examples:</p>

<pre><code>B = 50
D = 1500000
Cost: $0.536992840095   E = 2 c = 0.03
Cost: $2.14797136038    E = 2 c = 0.12
Cost: $3.75894988067    E = 2 c = 0.21
Cost: $0.894988066826   E = 1.2 c = 0.03
Cost: $3.5799522673     E = 1.2 c = 0.12
Cost: $6.26491646778    E = 1.2 c = 0.21
Cost: $3.5799522673     E = 0.3 c = 0.03
Cost: $14.3198090692    E = 0.3 c = 0.12
Cost: $25.0596658711    E = 0.3 c = 0.21

Cost: $0.171837708831   E = 25 c = 0.12
</code></pre>

<p>I chose 3 values for mining efficiency in Mhash/J: 2, 1.2 and 0.3 (the greater the better) and 3 values for electricity cost in USD: 0.03, 0.12, 0.21 (the smaller the better).<br>
Some boards, such as the 5850, have higher efficiency but we have to consider the system as a whole so 2 is still a high value. The average price of electricity per country can be found <a href="http://www.theoildrum.com/node/7215" rel="nofollow noreferrer">here</a>, but I am going to list a few examples:</p>

<ul>
<li>High electricity price - Ireland, Italy, Japan </li>
<li>Medium electricity price - US, France, Poland</li>
<li>Low electricity price - Mexico, Taiwan, Kazakhstan</li>
</ul>

<p>Using GPUs, the value ranges from $0.5 to $25 so it's not a small interval. The last line corresponds to the price of one bitcoin produced by an FPGA with electricity cost at $0.12 per KW/h: $0.17.</p>
 323: <p>As Bitcoin mining is very heterogeneous (that is, a lot of people use a wide variety of hardware), figuring this out would be really hard without the use of polling (as in, asking people questions, not long polling). One would need to get some statistical data on what hardware people have, how much they spend on electricity, and how much hashpower they have, not to mention how much they mine each day. Having all that, we could average it out and calculate something.</p>

<p>If you want to check how much your coin costs you, check out my calculator: <a href="http://tpbitcalc.appspot.com/" rel="nofollow">http://tpbitcalc.appspot.com/</a> .</p>
 575: <p>The parameters you need to calculate this are:</p>

<p>E - the mining efficiency, measured in MHash/J. Data on this for various hardware is available in <a href="https://en.bitcoin.it/wiki/Mining_hardware_comparison">Mining hardware comparison</a> (though this take into account only the card's power and not of the system it is in). Or you can calculate it for a given system by dividing the total hashrate (in MHash/s) by the power consumed (in W).</p>

<p>c - the cost of electricity, measured in $/KWh.</p>

<p>B - the bitcoin reward per block.</p>

<p>D - the difficulty.</p>

<p>The cost to generate 1 BTC is:</p>

<p>c*D/(838*B*E)</p>

<p>For example, if E=2, c=0.1, B=50 and D=1,500,000, this is
0.1*1500000/(838*50*2) = $1.79</p>

<p>The 838 "magic number" comes from the various unit conversion factors - 2^32 hashes per difficulty-1 hash, 3,600,000 Joules per Kilowatt-hour, 1,000,000 Hashes per MHash.</p>
