Skip to content

Instantly share code, notes, and snippets.

@mschauer
Last active August 13, 2017 13:26
Show Gist options
  • Select an option

  • Save mschauer/7cde501e4cea00a8b053b27b3f4210fa to your computer and use it in GitHub Desktop.

Select an option

Save mschauer/7cde501e4cea00a8b053b27b3f4210fa to your computer and use it in GitHub Desktop.
Bridge docs

Bridge.jl

Documentation for Bridge.jl

Important concepts

# Bridge.ContinuousTimeProcessType.

ContinuousTimeProcess{T}

Types inheriting from the abstract type ContinuousTimeProcess{T} characterize the properties of a T-valued stochastic process, play a similar role as distribution types like ``Exponentialin the packageDistributions`.

source

# Bridge.SamplePathType.

SamplePath{T} <: AbstractPath{T}

The struct

struct SamplePath{T}
    tt::Vector{Float64}
    yy::Vector{T}
    SamplePath{T}(tt, yy) where {T} = new(tt, yy)
end

serves as container for discretely observed $ContinuousTimeProcesses and for the sample path returned by direct and approximate samplers. tt$ is the vector of the grid points of the observation/simulation and yy is the corresponding vector of states.

It supports getindex, setindex!, length, copy, vcat, start, next, done, endof.

source

# Base.valtypeFunction.

valtype(::ContinuousTimeProcess) -> T

Returns statespace (type) of a ContinuousTimeProcess{T].

source

Ordinary differential equations

solve
solve!
R3
BS3

Brownian motion

Pages = ["/wiener.jl"]

Stochastic differential equations

sample
sample!
quvar
bracket
ito
girsanov
lp
llikelihood

Miscallenious

endpoint!

Unsorted

# Bridge.CSplineMethod.

CSpline(s, t, x, y = x, m0 = (y-x)/(t-s), m1 =  (y-x)/(t-s))

Cubic spline parametrized by f(s) = x and f(t) = y, f'(x) = m0, f'(t) = m1

source

# Bridge.GuidedPropType.

GuidedProp

General bridge proposal process

source

# Bridge.LinProType.

LinPro(B, μ::T, σ)

Linear diffusion $dX = B(X - μ)dt + σdW$

source

# Bridge.GammaProcessType.

GammaProcess

A GammaProcess with jump rate γ and inverse jump size λ has increments Gamma(t*γ, 1/λ) and Levy measure

$$ ν(x)=γ x^{-1}\exp(-λ x), $$

Here Gamma(α,θ) is the Gamma distribution in julia's parametrization with shape parameter α and scale θ

source

# Bridge.LocalGammaProcessType.

LocalGammaProcess

source

# Bridge.bracketMethod.

bracket(X)
bracket(X,Y)

Computes quadratic variation process of X (of X and Y).

source

# Bridge.bridgeFunction.

bridge(W, P, scheme! = euler!) -> Y

Integrate with $scheme!$ and set $Y[end] = P.v1$.

source

# Bridge.euler!Method.

euler!(Y, u, W, P) -> X

Solve stochastic differential equation $dX_t = b(t,X_t)dt + σ(t,X_t)dW_t$ using the Euler scheme in place.

source

# Bridge.eulerMethod.

euler(u, W, P) -> X

Solve stochastic differential equation $dX_t = b(t,X_t)dt + σ(t,X_t)dW_t$ using the Euler scheme.

source

# Bridge.girsanovMethod.

girsanov{T}(X::SamplePath{T}, P::ContinuousTimeProcess{T}, Pt::ContinuousTimeProcess{T})

Girsanov log likelihood $dP/dPt(X)$

source

# Bridge.itoMethod.

ito(Y, X)

Integrate a valued stochastic process with respect to a stochastic differential.

source

# Bridge.llikelihoodFunction.

Bridge log-likelihood with respect to reference measure P.P

Up to proportionality

source

# Bridge.llikelihoodFunction.

Log-likelihood with respect to reference measure P.P

Up to proportionality

source

# Bridge.llikelihoodMethod.

 llikelihood(X::SamplePath, P::ContinuousTimeProcess)

Log-likelihood of observations X using transition density lp

source

# Bridge.lpMethod.

lp(s, x, t, y, P)

Log-transition density, shorthand for logpdf(transitionprob(s,x,t,P),y).

source

# Bridge.mcbandMethod.

mcband(mc)

Compute marginal 95% coverage interval for the chain from normal approximation.

source

# Bridge.mcbandmeanMethod.

mcmeanband(mc)

Compute marginal confidence interval for the chain mean using normal approximation

source

# Bridge.mcnextMethod.

mcnext(state, x) -> state

Update random chain online statistics when new chain value x was observed. Return new state.

source

# Bridge.mcstartMethod.

mcstart(x) -> state

Create state for random chain online statitics. The entries/value of x are ignored

source

# Bridge.quvarMethod.

quvar(X)

Computes quadratic variation of X.

source

# Bridge.solve!Method.

solve!(method, X::SamplePath, x0, P) -> X, [err]

Solve ordinary differential equation (d/dx) x(t) = F(t, x(t), P) on the fixed grid X.tt writing into X.yy

method::R3 - using a non-adaptive Ralston (1965) update (order 3).

method::BS3 use non-adaptive Bogacki–Shampine method to give error estimate.

Call _solve! to inline. "Pretty fast if x is a bitstype or a StaticArray."

source

# Bridge.thetamethodFunction.

thetamethod(u, W, P, theta=0.5)

Solve stochastic differential equation using the theta method and Newton-Raphson steps

source

# StatsBase.sampleMethod.

 sample(tt, P, x1=zero(T))

Sample the process P on the grid tt exactly from its transitionprob(-ability) starting in x1.

source

# Bridge.PtildeMethod.

Ptilde(cs::CSpline, σ)

Affine diffusion $dX = cs(t) dt + σdW$ with cs a

source

# Bridge.BS3Type.

BS3()

Ralston (1965) update (order 3 step of the Bogacki–Shampine 1989 method) to solve $y(t + dt) - y(t) = int_t^{t+dt} f(s, y(s)) ds$. Uses Bogacki–Shampine method to give error estimate.

source

# Bridge.ODESolverType.

ODESolver

Abstract (super-)type for solving methods for ordinary differential equations.

source

# Bridge.R3Type.

R3()

Ralston (1965) update (order 3 step of the Bogacki–Shampine 1989 method) to solve $y(t + dt) - y(t) = int_t^{t+dt} f(s, y(s)) ds$.

source

# Base.valtypeMethod.

valtype(::ContinuousTimeProcess) -> T

Returns statespace (type) of a ContinuousTimeProcess{T].

source

# Bridge.VsFunction.

Vs (s, T1, T2, v, B, beta)

Time changed V for generation of U

source

# Bridge.compensatorMethod.

compensator(kstart, P::LocalGammaProcess)

Compensator of LocalGammaProcess

for kstart = 1, this is sum_k=1^N nu(B_k) for kstart = 0, this is sum_k=0^N nu(B_k) - C (where C is a constant)

source

# Bridge.compensator0Method.

compensator0(kstart, P::LocalGammaProcess)

Compensator of GammaProcess approximating the LocalGammaProcess. For kstart == 1 (only choice) this is nu([b1,Inf], P0)

source

# Bridge.cumsum0Method.

cumsum0

Cumulative sum starting at 0,

source

# Bridge.dotVsFunction.

dotVs (s, T, v, B, beta)

Time changed time derivative of V for generation of U

source

# Bridge.endpoint!Method.

endpoint!(X::SamplePath, v)

Convenience functions setting the endpoint of X``tov`.

source

# Bridge.gpK!Method.

gpK!(K::SamplePath, P)

Precompute $K = H^{-1}$ from $(d/dt)K = BK + KB' + a$ for a guided proposal.

source

# Bridge.integrateMethod.

integrate(cs::CSpline, s, t)

Integrate the cubic spline from s to t

source

# Bridge.logpdfnormalMethod.

logpdfnormal(x, A)

logpdf of centered gaussian with covariance A

source

# Bridge.matMethod.

mat(X::SamplePath{SVector}) 
mat(yy::Vector{SVector})

Reinterpret X or yy to an array without change in memory.

source

# Bridge.mdb!Method.

mdb(u, W, P)
mdb!(copy(W), u, W, P)

Euler scheme with the diffusion coefficient correction of the modified diffusion bridge.

source

# Bridge.mdbMethod.

mdb(u, W, P)
mdb!(copy(W), u, W, P)

Euler scheme with the diffusion coefficient correction of the modified diffusion bridge.

source

# Bridge.nuMethod.

(Bin-wise) integral of the Levy measure

source

# Bridge.outerMethod.

outer(x[, y])

Short-hand for quadratic form xx' (or xy').

source

# Bridge.rMethod.

r(t, x, T, v, P)

Returns $r(t,x) = \operatorname{grad}_x \log p(t,x; T, v)$ where $p$ is the transition density of the process $P$.

source

# Bridge.softFunction.

soft(t, T1, T2)

Time change mapping s in [T1, T2] (U-time) to t in [T1, T2] (X-time), and inverse.

source

# Bridge.tofsMethod.

tofs(s, T1, T2)
soft(t, T1, T2)

Time change mapping t in [T1, T2] (X-time) to s in [T1, T2]  (U-time).

source

# Bridge.θMethod.

Inverse jump size compared to gamma process with same alpha and beta

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment