<p>It is a <a href="https://en.wikipedia.org/wiki/Median" rel="nofollow noreferrer">median</a>, not an <a href="https://en.wikipedia.org/wiki/Average" rel="nofollow noreferrer">average</a>, thus it selects the 6th block's timestamp after sorting.</p>

<p>If you're a non-native English speaker, international maths heuristics can be quite tricky. Double-check on the Internet before translating into your head.</p>

CC BY-SA 4.0
2018-06-20T22:43:15.447Z
2019-09-24T13:40:50.093Z
2019-09-24T13:40:50.093Z
Paul Razvan Berg
<p>BIP 113's goal is <strong>not</strong> to aim for a specific offset.</p>

<p>Its goal is guaranteeing monotonicity (treating every block's timestamp as strictly larger than the timestamp of each of its ancestors). It does this by leveraging the <strong>existing</strong> consensus rule which states that the median of the timestamp of a block has to be strictly larger than the median of its 11 predecessors.</p>

<p>As to why the number 11 eleven was chosen in that existing consensus rule, we don't know. It was chosen by Bitcoin's creator.</p>

CC BY-SA 4.0
2018-06-20T22:46:46.713Z
As I also answered my question, the problem was specifically around the one-hour offset. I confused median with average, as I'm still getting used with maths in English.

But thank you for your answer, it provided clear and helpful info!
Paul Razvan Berg
CC BY-SA 4.0
2018-06-20T23:12:28.013Z
Median or average is not relevant. If the existing consensus rule would have been average, BIP113 would have chosen the same.
Pieter Wuille
CC BY-SA 4.0
2018-06-21T08:51:18.313Z
I agree, that stands for BIP113. However, we cannot know for sure that they would have selected the same number, ie 11, had the Bitcoin creator chosen the average not the median.
Paul Razvan Berg
CC BY-SA 4.0
2018-06-20T22:41:23.420Z
2018-06-20T22:41:23.420Z
Pieter Wuille
<p>For posterity, I want to share what I now believe to be the reason why 11-blocks was chosen for the <code>median_timestamp</code> calculation.</p>
<p>By calculating a median timestamp value of the previous 11 blocks, we derive a best-effort assumption of when a block was mined, 6 blocks prior, while accounting for the fact that the <code>timestamp</code> field is inexact.</p>
<p>This is to say that by enforcing that the <code>timestamp</code> of the current block must be greater than the <code>median_timestamp</code> <em>(the 'assumed actual timestamp')</em> of the trailing 6th-prior block, we allow a 1-hour fluctuation (on average) to the value that a miner attaches to the current block.</p>
<p>Simply:</p>
<p>6 blocks ago = 1 hour ago (on average) = a reasonable round number in wall-time to allow for fluctuation, when assigning the current block's timestamp</p>
<blockquote>
<p>thus it selects the 6th block's timestamp after sorting</p>
</blockquote>
<p>I believe this is what Paul meant here ^^^ but hopefully this detailed explanation is helpful to others.</p>

CC BY-SA 4.0
2023-07-02T22:10:37.577Z
2023-07-03T12:18:01.210Z
2023-07-03T12:18:01.210Z
sha2fiddy
<p>As described in <a href="https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki" rel="nofollow noreferrer">BIP-113</a>. Wouldn't the last 12 blocks bring us closer to a one-hour offset (ie 120min, midpoint 60)?</p>

<timestamp><bip><time>
Why does the median-past time average the last 11 block timestamps and not the last 12?
Paul Razvan Berg
# Why does the median-past time average the last 11 block timestamps and not the last 12?

(Asked by: username_0 on 2018-06-20)

As described in [BIP-113](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki). Wouldn't the last 12 blocks bring us closer to a one-hour offset (ie 120min, midpoint 60)?

**Tags:** timestamp, bip, time


---

## 3 answers

### Answer by username_0 on 2018-06-20. Score: 3 | Accepted answer

It is a [median](https://en.wikipedia.org/wiki/Median), not an [average](https://en.wikipedia.org/wiki/Average), thus it selects the 6th block's timestamp after sorting.

If you're a non-native English speaker, international maths heuristics can be quite tricky. Double-check on the Internet before translating into your head.


---

### Answer by username_1 on 2018-06-20. Score: 5

BIP 113's goal is **not** to aim for a specific offset.

Its goal is guaranteeing monotonicity (treating every block's timestamp as strictly larger than the timestamp of each of its ancestors). It does this by leveraging the **existing** consensus rule which states that the median of the timestamp of a block has to be strictly larger than the median of its 11 predecessors.

As to why the number 11 eleven was chosen in that existing consensus rule, we don't know. It was chosen by Bitcoin's creator.

> **Comments:**
> **username_0**: As I also answered my question, the problem was specifically around the one-hour offset. I confused median with average, as I'm still getting used with maths in English.  But thank you for your answer, it provided clear and helpful info!  
> **username_1**: Median or average is not relevant. If the existing consensus rule would have been average, BIP113 would have chosen the same.  
> **username_0**: I agree, that stands for BIP113. However, we cannot know for sure that they would have selected the same number, ie 11, had the Bitcoin creator chosen the average not the median.  

---

### Answer by username_2 on 2023-07-02. Score: 2

For posterity, I want to share what I now believe to be the reason why 11-blocks was chosen for the `median_timestamp` calculation.

By calculating a median timestamp value of the previous 11 blocks, we derive a best-effort assumption of when a block was mined, 6 blocks prior, while accounting for the fact that the `timestamp` field is inexact.

This is to say that by enforcing that the `timestamp` of the current block must be greater than the `median_timestamp` *(the 'assumed actual timestamp')* of the trailing 6th-prior block, we allow a 1-hour fluctuation (on average) to the value that a miner attaches to the current block.

Simply:

6 blocks ago = 1 hour ago (on average) = a reasonable round number in wall-time to allow for fluctuation, when assigning the current block's timestamp

> thus it selects the 6th block's timestamp after sorting

I believe this is what username_0 meant here ^^^ but hopefully this detailed explanation is helpful to others.


---

