# Documentation of aggregation methods would be nice

**URL:** <https://forum.beeminder.com/t/documentation-of-aggregation-methods-would-be-nice/549>\
**Category:** Bugabee\
**Created:** [February 28, 2015, 6:44pm UTC](https://forum.beeminder.com/t/documentation-of-aggregation-methods-would-be-nice/549 "2015-02-28T18:44:32Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [February 28, 2015, 10:43pm UTC](https://forum.beeminder.com/t/documentation-of-aggregation-methods-would-be-nice/549/4 "2015-02-28T22:43:45Z")

</div>

Great point, @drmaciver, and nice work digging up the answer from Akratics Anonymous, @chelsea

UPDATE 2018: The following table gives the aggday functions. They take the list `x` of raw datapoints on a given day and return the aggregated datapoint that is plotted and counts toward the Beeminder goal. In the actual Python code this is a hash of lambda functions. And `np` is NumPy.

UPDATE 2019: I added `cap1` and made it pseudocode instead of strictly Python.

```python
last : x[-1] # only the most recent datapoint entered that day counts
first : x[0] # only the first datapoint entered that day counts
min : min(x) # count the min of the day (default for weightloss)
max : max(x) # just count the max datapoint
truemean : mean(x) # use the mean of all datapoints
uniqmean : mean(deldups(x)) # mean of the unique values (shrug)
mean : # alias for uniqmean
median : median(x) # has this ever been used for any goal ever?
mode : mode(x) # technically: median of the commonest values
trimmean : trim_mean(x, .1) # another way to discount outliers
sum : sum(x) # what Do More and Do Less goals use
jolly : 1 if x else 0 # deprecated; now an alias for 'binary'
binary : 1 if x else 0 # 1 iff there exist any datapoints
nonzero : 1 if any([i!=0 for i in x]) else 0 # 1 iff any non-0 datapts
triangle : sum(x)*(sum(x)+1)/2 # blog.beeminder.com/triangle
square : sum(x)^2 # requested by DRMacIver
clocky : clocky(x) # sum of differences of pairs, HT @chipmanaged
count : len(x) # ignore values, just count number of datapoints
skatesum : min(rfin, sum(x)) # only count the daily min
cap1 : min(1, sum(x)) # the sum but capped at 1, HT @zedmango

def clocky(x):
  if len(x) % 2 != 0: x = x[:-1] # ignore last entry if unpaired
  return sum([end-start for [start,end] in partition(x,2,2)])

```

[Search keyword: “aggday docs”]

---

_[View the full topic](https://forum.beeminder.com/t/documentation-of-aggregation-methods-would-be-nice/549)._
