Moritz Schauer / Sep 11 2018
SamplePath
SamplePath
Pkg.pkg"add Bridge#master StaticArrays Colors GeometryTypes Distributions"
using Bridge, StaticArrays, Makie, Bridge.Models, Colors, GeometryTypes using Random, LinearAlgebra function viridis(s, alpha = 0.9f0, maxviri = 200) l, u = extrema(s) map(x->RGBA(Float32.(Bridge._viridis[1+floor(Int,x*maxviri)])..., alpha), (s .- l)/(u .- l)) end popdisplay(); # pop makie display
function viridis(s, alpha = 0.9f0, maxviri = 200) l, u = extrema(s) map(x->RGBA(Float32.(Bridge._viridis[1+floor(Int,x*maxviri)])..., alpha), (s .- l)/(u .- l)) end
# Continuous perspective t = 0:0.001:1.0 X = sample(t, Wiener()) lines(X.tt, X.yy)
# Discrete perspective Y = SamplePath(X.tt[1:20:end],X.yy[1:20:end]) scatter(Y.tt, Y.yy, markersize=0.02)
# Piecewise linear lines(Y.tt, Y.yy, markersize=0.02)
# Discrete perspective Y = SamplePath(X.tt[1:20:end],X.yy[1:20:end]) scatter(Y.tt, Y.yy, markersize=0.02)
# Piecewise constant Z = SamplePath(Bridge.piecewise(Y)...) lines(Z.tt, Z.yy)
# Jump process visualisation linesegments([(Point2f0(Y.tt[i], Y.yy[i]) => Point2f0(Y.tt[i+1], Y.yy[i])) for i in 1:length(Y)-1]) scatter!(Y.tt, Y.yy, markersize=0.01)
# 3D t = 0:0.001:1.0 X = sample(t, Wiener{SVector{3,Float64}}()) lines(X.yy, color=viridis(X.tt))
dump(VSamplePath(X.tt, [X.yy[i][k] for k in 1:3, i in 1:length(X.yy)]))
## Considerations for iteration protocol and interface # Subsampling Y = SamplePath(X.tt[1:10:end],X.yy[1:10:end]) # Seperation of time and space tt, yy = X.tt, X.yy # Often expressions of the following form needed i = 3 (tt[i]-tt[i+1])*yy[i]
# What should be the meaning of `X...`, `for it in X`? # t, x = tuple(X) # Is this nice? # Dict iterates pairs: println([Dict(2=>1, 1=>2) ...]) # Vector iterates values println([1,2]...)