# Mean Coin Age - Technical Details

## Definition

Recall that a coin-age model allows us at each given point in time to split all coins into segments where each segment has an assigned amount and creation timestamp . The set of all segments that exist at time will be denoted by .

Then, the formula for computing the mean coin age is:

Let us call the quantity in the numerator the total coin-age and denote it by . The quantity in the denominator is the total supply existing at time . We will call it

## Total supply

We can already compute the coin circulation. For each period , we can calculate the number of coins that have been active in the last days. Let us denote this amount by .

### Lemma

for sufficiently large. More precisely, the equality holds if is larger than the entire life of the coin.

## Total age

Let's focus on computing the total age of each coin. We have

We call the second summand the total creation timestamp. If we divide it by the token supply, we will get the mean creation timestamp . Hence we have the following formula:

In other words, the mean coin-age is equal to the current timestamp minus the mean creation timestamp.

## Total creation timestamp

According to the theory that we have already developed, we can efficiently compute the total creation timestamp. It is the metric associated to the function .

### Lemma

Let denote the event stream associated with the coin-age model . Then

The SQL statement for computing the real-time total creation timestamp delta is

1
2
3
4
5
6
SELECT
asset_id,
dt,
sum(sigma*odt*amount) as value
FROM {events}
GROUP BY asset_id, dt

In practice, we don't use the real-time delta functions. Instead, we use daily or five-minute deltas. We must construct those functions so that the value of the daily TCT is the same as the value of the real-time TCT at the start of each day. For the five-minute analog, a similar condition must hold. We have:

### Lemma

We compute the daily TCT delta using the following SQL:

1
2
3
4
5
6
SELECT
asset_id,
toStartOfDay(dt + 86400) AS daily_dt,
sum(sigma*odt*amount) AS value
FROM {events}
GROUP BY asset_id, daily_dt

We compute the five-minute TCT delta using the following SQL:

1
2
3
4
5
6
SELECT
asset_id,
toStartOfFiveMinutes(dt + 300) AS five_minute_dt,
sum(sigma*odt*amount) AS value
FROM {events}
GROUP BY asset_id, daily_dt

## Mean age computation

From the facts above, we can easily derive the mean coin-age. We first compute the daily or five-minute . Then we use a cumulative sum to calculate the daily five-minute total creation timestamp . From that, we can calculate the mean creation timestamp as a composite metric with the SQL formula:

1
total_creation_timestamp/circulation_20y

Finally, we can compute the mean coin-age as a composite metric with the SQL formula:

1
dt - mean_creation_timestamp

## Relation to age consumed

There is a relation between the total creation timestamp delta and the age consumed. The formula computes the age consumed (or coin-days destroyed):

So you have

The latter summand is the timestamp multiplied by the total supply delta at the time . If we choose a sufficiently large period , it is also equal to . So if we have already computed the age consumed, we can compute the delta total creation timestamp as a composite metric:

1
age_consumed + dt * circulation_delta_20y

However, our age consumed metric is measured in days. If we want the delta TCT to be measured in seconds the formula is

1
age_consumed*86400 + dt*circulation_delta_20y

If we want to measure it in days, then we have:

1
age_consumed + dt/86400 * circulation_delta_20y

In conclusion, once we have age_consumed and circulation, we can compute the mean coin age using only cumulative sums and composite metrics.