Skip to content

Instantly share code, notes, and snippets.

View mschauer's full-sized avatar

Moritz Schauer mschauer

View GitHub Profile
@mschauer
mschauer / bands.jl
Last active October 29, 2018 11:49
Makie confidence bands recipe
using Makie
import AbstractPlotting: plot!
@recipe(Band, x, ylower, yupper) do scene
Theme(;
default_theme(scene, Mesh)...,
color = RGBAf0(1.0,0,0,0.2)
)
end
@mschauer
mschauer / bench.jl
Created September 26, 2018 13:11
Flatten is fast
function interleave1(args::NTuple{N,Vector{T}}...) where {N,T}
n = minimum(length.(args))
c = Vector{T}(undef, length(arg)*n)
i = 0
for x in zip(args...)
for y in x
c[i += 1] = y
end
end
@mschauer
mschauer / wiener.ipynb
Last active October 4, 2018 04:08
Assortment of stochastic processes with Bridge.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mschauer
mschauer / unroll1.jl
Last active October 27, 2018 09:40
Unroll1
"""
@unroll1 for-loop
Unroll the first iteration of a `for`-loop.
Set `$first` to true in the first iteration.
Example:
```
@unroll1 for i in 1:10
if $first
@mschauer
mschauer / state.jl
Created October 20, 2018 19:08
Hamiltonian state
struct State{P}
q::Vector{P}
p::Vector{P}
end
q(x::State) = x.q
p(x::State) = x.p
q(x::State, i) = x.q[i]
p(x::State, i) = x.p[i]
@mschauer
mschauer / axes.md
Last active November 1, 2018 20:21
Axes

Axes

Axes can be realised as special margins or be displayed in the plot.

Elements of an axis

  • Axis location (at one of the margins or within the plot)
  • Axis lines
  • (Axis) arrows with arrowhead
  • Axis label, attached to or detached from arrow-head, e.g. measured quantity and unit
@mschauer
mschauer / ellipses.png
Last active November 6, 2018 14:03
Confidence ellipsoids for SDEs with Bridge and Makie
ellipses.png
@mschauer
mschauer / phylo.ipynb
Last active November 6, 2018 21:47
Sample Ornstein-Uhlenbeck process along a tree
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mschauer
mschauer / message.jl
Created November 13, 2018 17:08
Message passing with dynamic iterators
struct DZip{S,T}
X::S
Y::T
end
struct Start
end
struct End{T}
state::T
end
@mschauer
mschauer / stack.jl
Last active December 4, 2018 20:23
Stack filtered elements on top of iterator elements
struct Stack{I,F}
iter::I
f::F
end
import Base.iterate
function iterate(S::Stack)
ϕ = iterate(S.iter)