This file contains hidden or 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
[deps] | |
ArraysOfArrays = "65a8f2f4-9b39-5baf-92e2-a9cc46fdf018" | |
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" | |
MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" | |
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" | |
Pathfinder = "b1d3bc72-d0e7-4279-b92f-7fa5d6d2d454" | |
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" | |
ZigZagBoomerang = "36347407-b186-4a6a-8c98-4f4567861712" |
This file contains hidden or 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
#= | |
ZigZagBoomerang.jl has implemented something like a priority queue keeping track of | |
local minima (or high priority task). | |
Think of graph where vertices are tasks that are assigned priorities (smaller = higher priority) | |
and edges between two tasks indicate if the higher priority task has to be worked on before the | |
lower priority task (edge) or both can be worked on in parallel (no edge). | |
It’s thread-safe in the sense that priorities can be updated in different threads | |
if one has a proper coloring of the vertices and updates the task of one color in @threads |
This file contains hidden or 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
[deps] | |
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" | |
MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" | |
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" | |
Pathfinder = "b1d3bc72-d0e7-4279-b92f-7fa5d6d2d454" | |
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" | |
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" | |
SampleChainsDynamicHMC = "6d9fd711-e8b2-4778-9c70-c1dfb499d4c4" | |
Soss = "8ce77f84-9b61-11e8-39ff-d17a774bf41c" | |
TupleVectors = "615932cf-77b6-4358-adcd-5b7eba981d7e" |
This file contains hidden or 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
module Adamopt | |
# This is a module implementing vanilla Adam (https://arxiv.org/abs/1412.6980). | |
export Adam, step! | |
# Struct containing all necessary info | |
mutable struct Adam | |
theta::AbstractArray{Float64} # Parameter array | |
loss::Function # Loss function | |
grad::Function # Gradient function |
This file contains hidden or 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
using Distributions | |
# Search counter examples in exact arithmetic | |
xpdf(d::Binomial,k) = binomial(d.n, k)*d.p^k*(1 - d.p)^(d.n - k) | |
f(x,y) = x*y + (1-x)*(1-y) | |
while true |
This file contains hidden or 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
using Random, LinearAlgebra, Distributions, StatsBase | |
# Linear Algebra of Markov chain | |
# Example: Weather Markov chain of Oz | |
S = [:R, :S, :C] | |
P = [0.5 0.25 0.25 | |
0.5 0 0.5 | |
0.25 0.25 0.5] | |
sum(P[2, :]) |
This file contains hidden or 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
using Observables, BenchmarkTools, Test | |
struct StaticObservable{T, Listeners} <: Observables.AbstractObservable{T} | |
listeners::Listeners | |
val::Base.RefValue{T} | |
end | |
StaticObservable(obs::Observable) = StaticObservable(tuple(obs.listeners...), Ref(obs[])) | |
function StaticObservable(val::Ref, listeners...) | |
_notify(val, listeners) |
This file contains hidden or 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
n = 1000 | |
x = range(0, 1, length=n) | |
ς = 1.5 # noise level | |
μ = 3*x.*sin.(2pi*x) # periodic signal in time domain | |
#μ = 6*sqrt.(abs.(x .- 0.5)) # this one is difficult to estimate | |
# Model: Signal distorted by white noise | |
y = μ + ς*randn(n) |
This file contains hidden or 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
using Mitosis | |
using MitosisStochasticDiffEq | |
import MitosisStochasticDiffEq as MSDE | |
using StaticArrays, LinearAlgebra | |
using OrdinaryDiffEq | |
# Match with B and sigma | |
B(θ) = [-0.1 0.2θ; -0.2θ -0.1] | |
beta(θ) = [0.,0.] | |
Σ(θ) = 0.15*I(2) |