Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mschauer/Bridge.jl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.8.0
Choose a base ref
...
head repository: mschauer/Bridge.jl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 6,471 additions and 1,550 deletions.
  1. +45 −0 .github/workflows/CI.yml
  2. +19 −0 .github/workflows/CompatHelper.yml
  3. +15 −0 .github/workflows/TagBot.yml
  4. +1 −0 .gitignore
  5. +0 −16 .travis.yml
  6. +39 −0 Project.toml
  7. +25 −14 README.md
  8. +5 −4 REQUIRE
  9. +5 −0 docs/Project.toml
  10. +0 −5 docs/make.jl
  11. BIN docs/src/assets/levyou.png
  12. BIN docs/src/assets/ou.png
  13. +5 −7 docs/src/index.md
  14. +15 −10 docs/src/library.md
  15. +4 −3 docs/src/manual.md
  16. +460 −544 example/3DExamples.ipynb
  17. +4 −4 example/arctan.jl
  18. +7 −7 example/ellipt.jl
  19. +4 −4 example/fitzhugh_nagumo.jl
  20. +4 −4 example/fitzhugh_nagumo_full.jl
  21. +4 −4 example/fitzhugh_nagumo_theta.jl
  22. +3 −3 example/gamma.jl
  23. +6 −6 example/hypo.jl
  24. +18 −19 example/tutorial.jl
  25. +17 −7 extra/makie.jl
  26. +14 −14 project/gamma3.jl
  27. +2 −2 project/hyposmoothing.jl
  28. +2 −2 project/makie.jl
  29. +4 −4 project/partial.jl
  30. +154 −0 project/partialbridge.jl
  31. +217 −0 project/partialbridge_fitzhugh.jl
  32. +2 −2 project/plotgamma3.jl
  33. +466 −0 project_partialbridge/partialbridge_bolus2.jl
  34. +491 −0 project_partialbridge/partialbridge_bolus3.jl
  35. +215 −0 project_partialbridge/partialbridge_fitzhugh.jl
  36. +233 −0 project_partialbridge/partialbridge_landmarks.jl
  37. +170 −0 project_partialbridge/partialbridge_nclar.jl
  38. +158 −0 project_partialbridge/partialbridge_quipexample.jl
  39. +101 −0 project_partialbridge/truepaths_fh.jl
  40. +66 −0 project_partialbridge/truepaths_nclar.jl
  41. +44 −20 src/Bridge.jl
  42. +7 −7 src/Models.jl
  43. +48 −23 src/bessel.jl
  44. +10 −11 src/chol.jl
  45. +10 −38 src/deprecated.jl
  46. +21 −18 src/diffusion.jl
  47. +118 −89 src/euler.jl
  48. +30 −19 src/expint.jl
  49. +9 −9 src/gaussian.jl
  50. +33 −0 src/gode.jl
  51. +7 −9 src/guip!.jl
  52. +105 −114 src/guip.jl
  53. +46 −21 src/levy.jl
  54. +32 −35 src/linpro.jl
  55. +17 −0 src/lyap.jl
  56. +214 −11 src/mclog.jl
  57. +51 −23 src/misc.jl
  58. +30 −3 src/ode!.jl
  59. +46 −65 src/ode.jl
  60. +87 −0 src/partialbridge.jl
  61. +121 −0 src/partialbridgen!.jl
  62. +189 −0 src/partialbridgenuH.jl
  63. +1 −1 src/poisson.jl
  64. +50 −34 src/sde!.jl
  65. +42 −0 src/sde.jl
  66. +14 −14 src/timechange.jl
  67. +44 −21 src/types.jl
  68. +62 −0 src/unroll1.jl
  69. +17 −17 src/wiener.jl
  70. +1 −1 supplements/smoothing/figsmoothing1.jl
  71. +2 −2 supplements/smoothing/figsmoothing2.jl
  72. +3 −3 supplements/smoothing/figsmoothing3.jl
  73. +2 −2 supplements/smoothing/figsmoothing4.jl
  74. +3 −3 supplements/smoothing/figsmoothing5.jl
  75. +3 −3 supplements/smoothing/figsmoothing6.jl
  76. +2 −2 supplements/smoothing/lorenz.jl
  77. +2 −2 supplements/smoothing/pendulum.jl
  78. +6 −6 supplements/smoothing/smoothing.jl
  79. +13 −13 supplements/smoothing/smoothing2d.jl
  80. +323 −0 supplements/volatility/CIR.jl
  81. +214 −0 supplements/volatility/Volatility.jl
  82. +227 −0 supplements/volatility/blocks.jl
  83. +241 −0 supplements/volatility/dwj.jl
  84. +24 −0 supplements/volatility/figprior.jl
  85. +40 −0 supplements/volatility/figprior2.jl
  86. +105 −0 supplements/volatility/setup.jl
  87. +0 −1 test/SEED
  88. +15 −17 test/VHK.jl
  89. +18 −19 test/bessel.jl
  90. +14 −14 test/diffusion.jl
  91. +3 −3 test/euler.jl
  92. +26 −0 test/expint.jl
  93. +4 −4 test/gamma.jl
  94. +40 −36 test/gaussian.jl
  95. +45 −45 test/guip.jl
  96. +3 −3 test/inno.jl
  97. +1 −1 test/levysde.jl
  98. +6 −6 test/linpro.jl
  99. +2 −2 test/linprobridge.jl
  100. +24 −0 test/lyap.jl
  101. +6 −6 test/misc.jl
  102. +13 −0 test/onlinestat.jl
  103. +115 −0 test/partialbridge!.jl
  104. +121 −0 test/partialbridge.jl
  105. +208 −0 test/partialbridgenuH.jl
  106. +14 −0 test/partialparam.jl
  107. +2 −2 test/perf/lorenz.jl
  108. +2 −2 test/perf/runbench.jl
  109. +11 −4 test/runtests.jl
  110. +12 −11 test/smoothing.jl
  111. +37 −37 test/timechange.jl
  112. +2 −2 test/types.jl
  113. +2 −2 test/uniformscaling.jl
  114. +5 −5 test/wiener.jl
  115. +4 −4 test/with_srand.jl
45 changes: 45 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI
on:
pull_request:
push:
branches:
- master
tags: '*'
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
# - 'nightly'
- '1.5'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
19 changes: 19 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CompatHelper

on:
schedule:
- cron: '00 00 * * *'

jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: 1.3
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
output
test/perf/*.jld
.*
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

39 changes: 39 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name = "Bridge"
uuid = "2d3116d5-4b8f-5680-861c-71f149790274"
authors = ["Moritz Schauer <moritzschauer@web.de>"]
version = "0.11.7"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
Trajectories = "2c80a279-213e-54d7-a557-e9a14725db56"

[compat]
Colors = "0.9, 0.10, 0.11, 0.12"
Distributions = "0.22, 0.23, 0.24, 0.25"
Polynomials = "0.6, 0.7, 0.8, 1.1, 2.0"
RecipesBase = "0.7, 0.8, 1.0"
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 1.1, 1.2"
StaticArrays = "0.12, 1.0, 1.1"
Trajectories = "0.1, 0.2"
julia = "1"

[extras]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Statistics", "Documenter", "LinearAlgebra", "Test", "Random"]
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,9 +5,12 @@
![Logo](https://mschauer.github.io/Bridge.jl/bridgelogo.gif)

# Bridge.jl

Stochastic calculus and univariate and multivariate stochastic processes/Markov processes in continuous time.
See [./example/tutorial.jl](./example/tutorial.jl) for an introduction. I am personally interested in simulating diffusion bridges and doing Bayesian inference on discretely observed diffusion processes, but this package is written to be of general use and contributions are welcome.

Statistics and stochastic calculus for Markov processes in continuous time, include univariate and multivariate stochastic processes such as stochastic differential equations or diffusions (SDE's) or Levy processes.

I am personally interested in doing Bayesian inference on discretely observed diffusion processes, but this package is written to be of general use and contributions are welcome.
Specifically for our code for parameter inference for diffusion processes from discrete data or passage times, check out the dependent package [BridgeSDEInference.jl](https://github.com/mmider/BridgeSDEInference.jl).
The statistical method relies a lot on simulating conditional diffusions (so called "difffusion bridges"). See [./example/tutorial.jl](./example/tutorial.jl) for a more general introduction into working with this package.

- [x] Define and simulate diffusion processes in one or more dimension
- [x] Continuous and discrete likelihood using Girsanovs theorem and transition densities
@@ -32,7 +35,7 @@ The example programs in the example/ directory have additional dependencies: Con

The key objects introduced are the abstract type `ContinuousTimeProcess{T}` parametrised by the state space of the path, for example `T == Float64` and various `structs` suptyping it, for example `Wiener{Float64}` for a real Brownian motion. These play roughly a similar role as types subtyping `Distribution` in the Distributions.jl package.

Secondly, the struct
Secondly, the struct
```julia
struct SamplePath{T}
tt::Vector{Float64}
@@ -61,29 +64,37 @@ It is also quite transparent how to add a new process:

```julia
using Bridge
using Plots

# Define a diffusion process
struct OrnsteinUhlenbeck <: ContinuousTimeProcess{Float64}
β::Float64 # drift parameter (also known as inverse relaxation time)
σ::Float64 # diffusion parameter
function OrnsteinUhlenbeck::Float64, σ::Float64)
isnan(β) || β > 0. || error("Parameter λ must be positive.")
isnan(σ) || σ > 0. || error("Parameter σ must be positive.")
new(β, σ)
end
end

# define drift and diffusion coefficient of OrnsteinUhlenbeck
import Bridge: b, σ, a, transitionprob
Bridge.b(t,x, P::OrnsteinUhlenbeck) = -P.β*x
Bridge.b(t, x, P::OrnsteinUhlenbeck) = -P.β*x
Bridge.σ(t, x, P::OrnsteinUhlenbeck) = P.σ
Bridge.a(t, x, P::OrnsteinUhlenbeck) = P.σ^2

# simulate OrnsteinUhlenbeck using Euler scheme
W = sample(0:0.01:10, Wiener())
X = solve(EulerMaruyama(), 0.1, W, OrnsteinUhlenbeck(20.0, 1.0))
W = sample(0:0.01:10, Wiener())
X = solve(EulerMaruyama(), 0.1, W, OrnsteinUhlenbeck(2.0, 1.0))
plot(X, label="X")
```

![OrnsteinUhlenbeck](https://mschauer.github.io/Bridge.jl/latest/assets/ou.png)

```julia
# Levy (Difference-Gamma process) driven OrnsteinUhlenbeck
Z = sample(0:0.01:10, GammaProcess(100.0,10.0))
Z.yy .-= sample(0:0.01:10, GammaProcess(100.0,10.0)).yy
Y = solve(EulerMaruyama(), 0.1, Z, OrnsteinUhlenbeck(2.0, 1.0))
plot(Y, label="Y")
```

![Levy OrnsteinUhlenbeck](https://mschauer.github.io/Bridge.jl/latest/assets/levyou.png)


## Feedback and Contributing

See the [documentation](https://mschauer.github.io/Bridge.jl/latest/) for more functionality and [issue #12 (Feedback and Contribution)](https://github.com/mschauer/Bridge.jl/issues/12) for coordination of the development.
9 changes: 5 additions & 4 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
julia 0.6 0.7
julia 0.7
Polynomials
Distributions 0.11.1
StaticArrays 0.6.3
Compat 0.28.0
Distributions
StaticArrays
RecipesBase
Colors
Trajectories
5 changes: 5 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "0.24"
5 changes: 0 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ using Bridge

makedocs(
modules = [Bridge],
format = :html,
sitename = "Bridge.jl",
authors = "Moritz Schauer and contributors",
pages = Any[ # Compat: `Any` for 0.4 compat
@@ -18,8 +17,4 @@ makedocs(
# for more information.
deploydocs(
repo = "github.com/mschauer/Bridge.jl.git",
julia = "0.6",
target = "build",
deps = nothing,
make = nothing,
)
Binary file added docs/src/assets/levyou.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/ou.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 5 additions & 7 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -11,21 +11,19 @@ Secondly, 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 sample path returned by direct and approximate samplers (`sample`, `euler`, ...).
`tt` is the vector of the grid points of the simulation and `yy` the corresponding vector of states.

Help is available at the REPL:
```
help?> euler
search: euler euler! eulergamma default_worker_pool schedule @schedule
help?> Bridge.ContinuousTimeProcess
ContinuousTimeProcess{T}
euler(u, W, P) -> X
Solve stochastic differential equation ``dX_t = b(t, X_t)dt + σ(t, X_t)dW_t, X_0 = u``
using the Euler scheme.
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 Exponential in the package Distributions.
```

Pre-defined processes defined are
25 changes: 15 additions & 10 deletions docs/src/library.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ Bridge.outertype
```@docs
Bridge.ODESolver
solve!
Bridge.solvebackward!
Bridge.R3
Bridge.BS3
LeftRule
@@ -42,8 +43,6 @@ girsanov
lp
llikelihood
solve
euler
euler!
EulerMaruyama
Euler
StochasticRungeKutta
@@ -56,6 +55,7 @@ Bridge.NoDrift
Bridge.R3!
Bridge.σ!
Bridge.b!
Bridge.kernelr3!
```

## Levy processes
@@ -76,6 +76,7 @@ InhomogPoisson

## Bessel processes
```@docs
Bridge.Bessel{N}
Bridge.Bessel3Bridge
Bridge.BesselProp
```
@@ -89,14 +90,16 @@ Bridge.cumsum0
Bridge.mat
Bridge.outer
CSpline
Bridge.integrate
Bridge.integrate
Bridge.logpdfnormal
Bridge.runmean
Bridge.PSD
Bridge.Gaussian
Bridge.refine
Bridge.quaternion
Bridge._viridis
Bridge.supnorm
Bridge.posterior
```

## Online statistics
@@ -116,6 +119,7 @@ mcband
mcbandmean
Bridge.mcstats
Bridge.mcmarginalstats
Bridge.OnlineStat
```

## Linear Processes
@@ -134,11 +138,10 @@ Bridge.LinProBridge
```@docs
GuidedProp
Bridge.GuidedBridge
BridgePre
Bridge.PartialBridge
Bridge.PartialBridgeνH
BridgeProp
Bridge.Mdb
bridge
bridge!
Bridge.Vs
Bridge.gpV!
Bridge.r
@@ -150,17 +153,19 @@ Bridge.gpupdate

```@docs
LocalGammaProcess
Bridge.compensator0
Bridge.compensator0
Bridge.compensator
Bridge.θ
Bridge.θ
Bridge.soft
Bridge.tofs
Bridge.dotVs
Bridge.SDESolver
Bridge.Increments
Bridge.sizedtype
Bridge.piecewise
Bridge.BridgePre!
Bridge.aeuler
Bridge.MeanCov
Bridge.upsample
Bridge.viridis
Bridge.rescale
```

Loading