Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
7,469 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
output | ||
test/perf/*.jld | ||
.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,259 @@ | ||
# This file is machine-generated - editing it directly is not advised | ||
|
||
[[Arpack]] | ||
deps = ["BinaryProvider", "Libdl", "LinearAlgebra", "Random", "SparseArrays", "Test"] | ||
git-tree-sha1 = "1ce1ce9984683f0b6a587d5bdbc688ecb480096f" | ||
uuid = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97" | ||
version = "0.3.0" | ||
|
||
[[Base64]] | ||
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" | ||
|
||
[[BinDeps]] | ||
deps = ["Compat", "Libdl", "SHA", "URIParser"] | ||
git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" | ||
uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" | ||
version = "0.8.10" | ||
|
||
[[BinaryProvider]] | ||
deps = ["Libdl", "SHA"] | ||
git-tree-sha1 = "c7361ce8a2129f20b0e05a89f7070820cfed6648" | ||
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" | ||
version = "0.5.4" | ||
|
||
[[ColorTypes]] | ||
deps = ["FixedPointNumbers", "Random", "Test"] | ||
git-tree-sha1 = "f73b0e10f2a5756de7019818a41654686da06b09" | ||
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" | ||
version = "0.7.5" | ||
|
||
[[Colors]] | ||
deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Printf", "Reexport", "Test"] | ||
git-tree-sha1 = "9f0a0210450acb91c730b730a994f8eef1d3d543" | ||
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" | ||
version = "0.9.5" | ||
|
||
[[Compat]] | ||
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] | ||
git-tree-sha1 = "84aa74986c5b9b898b0d1acaf3258741ee64754f" | ||
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" | ||
version = "2.1.0" | ||
|
||
[[DataStructures]] | ||
deps = ["InteractiveUtils", "OrderedCollections", "Random", "Serialization", "Test"] | ||
git-tree-sha1 = "ca971f03e146cf144a9e2f2ce59674f5bf0e8038" | ||
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" | ||
version = "0.15.0" | ||
|
||
[[Dates]] | ||
deps = ["Printf"] | ||
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
|
||
[[DelimitedFiles]] | ||
deps = ["Mmap"] | ||
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" | ||
|
||
[[Distributed]] | ||
deps = ["Random", "Serialization", "Sockets"] | ||
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" | ||
|
||
[[Distributions]] | ||
deps = ["LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"] | ||
git-tree-sha1 = "56a158bc0abe4af5d4027af2275fde484261ca6d" | ||
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" | ||
version = "0.19.2" | ||
|
||
[[FixedPointNumbers]] | ||
deps = ["Test"] | ||
git-tree-sha1 = "b8045033701c3b10bf2324d7203404be7aef88ba" | ||
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" | ||
version = "0.5.3" | ||
|
||
[[InteractiveUtils]] | ||
deps = ["Markdown"] | ||
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | ||
|
||
[[IteratorInterfaceExtensions]] | ||
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" | ||
uuid = "82899510-4779-5014-852e-03e436cf321d" | ||
version = "1.0.0" | ||
|
||
[[LibGit2]] | ||
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" | ||
|
||
[[Libdl]] | ||
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | ||
|
||
[[LinearAlgebra]] | ||
deps = ["Libdl"] | ||
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
|
||
[[Logging]] | ||
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" | ||
|
||
[[Markdown]] | ||
deps = ["Base64"] | ||
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" | ||
|
||
[[Missings]] | ||
deps = ["Dates", "InteractiveUtils", "SparseArrays", "Test"] | ||
git-tree-sha1 = "d1d2585677f2bd93a97cfeb8faa7a0de0f982042" | ||
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" | ||
version = "0.4.0" | ||
|
||
[[Mmap]] | ||
uuid = "a63ad114-7e13-5084-954f-fe012c677804" | ||
|
||
[[OrderedCollections]] | ||
deps = ["Random", "Serialization", "Test"] | ||
git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1" | ||
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
version = "1.1.0" | ||
|
||
[[PDMats]] | ||
deps = ["Arpack", "LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"] | ||
git-tree-sha1 = "8b68513175b2dc4023a564cb0e917ce90e74fd69" | ||
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150" | ||
version = "0.9.7" | ||
|
||
[[Pkg]] | ||
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] | ||
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
|
||
[[Polynomials]] | ||
deps = ["LinearAlgebra", "SparseArrays", "Test"] | ||
git-tree-sha1 = "62142bd65d3f8aeb2226ec64dd8493349147df94" | ||
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" | ||
version = "0.5.2" | ||
|
||
[[Printf]] | ||
deps = ["Unicode"] | ||
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" | ||
|
||
[[QuadGK]] | ||
deps = ["DataStructures", "LinearAlgebra", "Test"] | ||
git-tree-sha1 = "3ce467a8e76c6030d4c3786e7d3a73442017cdc0" | ||
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" | ||
version = "2.0.3" | ||
|
||
[[REPL]] | ||
deps = ["InteractiveUtils", "Markdown", "Sockets"] | ||
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" | ||
|
||
[[Random]] | ||
deps = ["Serialization"] | ||
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
|
||
[[RecipesBase]] | ||
deps = ["Random", "Test"] | ||
git-tree-sha1 = "0b3cb370ee4dc00f47f1193101600949f3dcf884" | ||
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" | ||
version = "0.6.0" | ||
|
||
[[Reexport]] | ||
deps = ["Pkg"] | ||
git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0" | ||
uuid = "189a3867-3050-52da-a836-e630ba90ab69" | ||
version = "0.2.0" | ||
|
||
[[Requires]] | ||
deps = ["Test"] | ||
git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1" | ||
uuid = "ae029012-a4dd-5104-9daa-d747884805df" | ||
version = "0.5.2" | ||
|
||
[[Rmath]] | ||
deps = ["BinaryProvider", "Libdl", "Random", "Statistics", "Test"] | ||
git-tree-sha1 = "9a6c758cdf73036c3239b0afbea790def1dabff9" | ||
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa" | ||
version = "0.5.0" | ||
|
||
[[SHA]] | ||
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" | ||
|
||
[[Serialization]] | ||
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | ||
|
||
[[SharedArrays]] | ||
deps = ["Distributed", "Mmap", "Random", "Serialization"] | ||
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" | ||
|
||
[[Sockets]] | ||
uuid = "6462fe0b-24de-5631-8697-dd941f90decc" | ||
|
||
[[SortingAlgorithms]] | ||
deps = ["DataStructures", "Random", "Test"] | ||
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd" | ||
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" | ||
version = "0.3.1" | ||
|
||
[[SparseArrays]] | ||
deps = ["LinearAlgebra", "Random"] | ||
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
|
||
[[SpecialFunctions]] | ||
deps = ["BinDeps", "BinaryProvider", "Libdl", "Test"] | ||
git-tree-sha1 = "0b45dc2e45ed77f445617b99ff2adf0f5b0f23ea" | ||
uuid = "276daf66-3868-5448-9aa4-cd146d93841b" | ||
version = "0.7.2" | ||
|
||
[[StaticArrays]] | ||
deps = ["InteractiveUtils", "LinearAlgebra", "Random", "Statistics", "Test"] | ||
git-tree-sha1 = "3841b39ed5f047db1162627bf5f80a9cd3e39ae2" | ||
uuid = "90137ffa-7385-5640-81b9-e52037218182" | ||
version = "0.10.3" | ||
|
||
[[Statistics]] | ||
deps = ["LinearAlgebra", "SparseArrays"] | ||
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
|
||
[[StatsBase]] | ||
deps = ["DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics"] | ||
git-tree-sha1 = "8a0f4b09c7426478ab677245ab2b0b68552143c7" | ||
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" | ||
version = "0.30.0" | ||
|
||
[[StatsFuns]] | ||
deps = ["Rmath", "SpecialFunctions", "Test"] | ||
git-tree-sha1 = "b3a4e86aa13c732b8a8c0ba0c3d3264f55e6bb3e" | ||
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c" | ||
version = "0.8.0" | ||
|
||
[[SuiteSparse]] | ||
deps = ["Libdl", "LinearAlgebra", "SparseArrays"] | ||
uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" | ||
|
||
[[TableTraits]] | ||
deps = ["IteratorInterfaceExtensions"] | ||
git-tree-sha1 = "b1ad568ba658d8cbb3b892ed5380a6f3e781a81e" | ||
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" | ||
version = "1.0.0" | ||
|
||
[[Tables]] | ||
deps = ["IteratorInterfaceExtensions", "LinearAlgebra", "Requires", "TableTraits", "Test"] | ||
git-tree-sha1 = "9e748316f5aa7b7753c90de612ef98fe8b0ea297" | ||
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
version = "0.2.1" | ||
|
||
[[Test]] | ||
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] | ||
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[[Trajectories]] | ||
deps = ["RecipesBase", "Tables", "Test"] | ||
git-tree-sha1 = "12e44c9a3517570935b14f9e3969fe2134cafff2" | ||
uuid = "2c80a279-213e-54d7-a557-e9a14725db56" | ||
version = "0.1.0" | ||
|
||
[[URIParser]] | ||
deps = ["Test", "Unicode"] | ||
git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" | ||
uuid = "30578b45-9adc-5946-b283-645ec420af67" | ||
version = "0.4.0" | ||
|
||
[[UUIDs]] | ||
deps = ["Random", "SHA"] | ||
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" | ||
|
||
[[Unicode]] | ||
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ Polynomials | |
Distributions | ||
StaticArrays | ||
RecipesBase | ||
Colors | ||
Colors | ||
Trajectories |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ Bridge.NoDrift | |
Bridge.R3! | ||
Bridge.σ! | ||
Bridge.b! | ||
Bridge.kernelr3! | ||
``` | ||
|
||
## Levy processes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using ForwardDiff | ||
|
||
# convert dual to float, while retaining float if type is float | ||
deepvalue(x::Float64) = x | ||
deepvalue(x::ForwardDiff.Dual) = ForwardDiff.value(x) | ||
deepvalue(x) = deepvalue.(x) | ||
|
||
# here is a slight adaptation of Marcin's function solveAndll! | ||
# should be able to get gradient information for starting point; new guided proposal is written into X | ||
function solveAndll!(::EulerMaruyama, x0::T, W::SamplePath, X, P::GuidPropBridge, θ) where T | ||
N = length(W) | ||
N != length(X) && error("Y and W differ in length.") | ||
|
||
tt = Y.tt | ||
X.yy[1] .= deepvalue(x0) | ||
y = copy(x0) | ||
ll::T = 0. | ||
ww = W.yy | ||
|
||
ll::T = 0.0 | ||
for i in 1:N-1 | ||
yy[.., i] = y | ||
dWt = ww[.., i+1]-ww[.., i] | ||
s = tt[i] | ||
dt = tt[i+1]-tt[i] | ||
b_prop = _b((i,s), y, P, θ) | ||
y = y + b_prop*dt + _scale(dWt, σ(s, y, P, θ)) | ||
|
||
b_trgt = _b((i,s), y, target(P), θ) | ||
b_aux = _b((i,s), y, auxiliary(P), θ) | ||
rₜₓ = r((i,s), y, P, θ) | ||
ll += dot(b_trgt-b_aux, rₜₓ) * dt | ||
|
||
if !constdiff(P) | ||
Hₜₓ = H((i,s), y, P, θ) | ||
aₜₓ = a((i,s), y, target(P), θ) | ||
ãₜ = ã((i,s), y, P, θ) | ||
ll -= 0.5*sum( (aₜₓ - ãₜ).*Hₜₓ ) * dt | ||
ll += 0.5*( rₜₓ'*(aₜₓ - ãₜ)*rₜₓ ) * dt | ||
end | ||
X.yy[i+1] .= deepvalue(y) | ||
end | ||
copyto!(X.yy[end], Bridge.endpoint(X.yy[end],P)) | ||
ll # here the log of rhotilde(0,x0) should be added to ll, Marcin probabably wrote a function for that (please check it is Dual-number 'proof') | ||
end | ||
|
||
|
||
|
||
# apply as follows: | ||
slogρ(W, X, P, θ) = (x0) -> solveAndll!(LeftRule(), 0x, W, X, P, θ) | ||
∇x0 = copy(x0) | ||
# following returns the gradient, for starting point x and writes it into ∇x | ||
ForwardDiff.gradient!(∇x0, slogρ(W, X, P, θ),x0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
using DualNumbers | ||
|
||
# small test to understand | ||
ff(x) = x^3 | ||
ff(Dual(2,1)) | ||
|
||
# Redefine | ||
# const Point = SArray{Tuple{d},Float64,1,d} # point in R2 | ||
# const Unc = SArray{Tuple{d,d},Float64,d,d*d} # Matrix presenting uncertainty | ||
# to | ||
|
||
const Point{T} = SArray{Tuple{d},T,1,d} | ||
const Unc{T} = SArray{Tuple{d,d},T,d,d*d} | ||
# > Point{Dual{Float64}}(rand(3)) | ||
|
||
# matrix multiplication of mat of Uncs | ||
function Base.:*(A::Array{Unc{T},2},B::Array{Unc{T},2}) where T | ||
C = zeros(Unc{T},size(A,1), size(B,2)) | ||
for i in 1:size(A,1) | ||
for j in 1:size(B,2) | ||
for k in 1:size(A,2) | ||
C[i,j] += A[i,k] * B[k,j] | ||
end | ||
end | ||
end | ||
C | ||
end | ||
|
||
function Base.:*(A::Array{Unc,2},x::State) | ||
vecofpoints2state(A*vec(x)) | ||
end | ||
|
||
|
||
# DON'T NEED THIS PROBABLY | ||
# | ||
# function ll(x0,XX,Q) | ||
# XX.yy[1] = deepvec2state(x0) | ||
# llikelihood(LeftRule(), XX, Q; skip = 0) | ||
# end | ||
# y0 = deepvec(x0) | ||
# ll(y0,XX,Q) | ||
# | ||
# F(XX,Q) = (x) -> ll(x, XX,Q) | ||
# F(XX,Q)(y0) | ||
# using ForwardDiff | ||
# | ||
# g = x0 -> ForwardDiff.gradient(F(XX,Q), x0) # g = ∇f | ||
# g(deepvec(x0)) |
Oops, something went wrong.