Skip to content

Instantly share code, notes, and snippets.

@i-like-bikes
Created November 29, 2017 12:43
Show Gist options
  • Select an option

  • Save i-like-bikes/591431a335d814b4568d8f94a70484c1 to your computer and use it in GitHub Desktop.

Select an option

Save i-like-bikes/591431a335d814b4568d8f94a70484c1 to your computer and use it in GitHub Desktop.

Revisions

  1. i-like-bikes created this gist Nov 29, 2017.
    19 changes: 19 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    q)rng: {[w;s;e] s + w*til ceiling(e-s)%w}
    q)dt: rng[1;2000.01.01;2001.01.01] / generates list of dates for the year
    q)data: {til x}'[(count dt)?1000] / generate some random data, sampling from 1000 - so avg should be about 500 a day.
    q)tab: ungroup ([]date:{(count x)#y}'[data;dt];observation:data) / this is shit - but yknow, 6 months since paid for this shit
    q)select avg dayCount by date.month from select dayCount: count i by date from tab / Damn son, that daily agg, turned into monthly avg.
    month | dayCount
    -------| --------
    2000.01| 472.871
    2000.02| 507.2759
    2000.03| 477.6452
    2000.04| 456.8
    2000.05| 464.0323
    2000.06| 546.3333
    2000.07| 587.0323
    2000.08| 537.2581
    2000.09| 591.8
    2000.10| 466.2581
    2000.11| 500.1667
    2000.12| 471.6774