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
##### | |
##### Self-contained example to dissect broken tests in | |
##### https://github.com/JuliaDiffEq/DiffEqBayes.jl/blob/e033307768892e2f7242ae0aab3e09ec4819c11b/test/dynamicHMC.jl | |
##### | |
##### NOTE: you need DynamicHMC#master and LogDensityProblems#0.9.x for this to work | |
#### | |
#### part that just relies on the DiffEq ecosystem | |
#### |
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
[[AltDistributions]] | |
deps = ["ArgCheck", "Distributions", "DocStringExtensions", "ForwardDiff", "LinearAlgebra", "Parameters", "Random", "SpecialFunctions", "StatsFuns"] | |
path = "/home/tamas/code/julia/AltDistributions" | |
uuid = "875e7ca2-ab9d-5828-93ae-a098eac53262" | |
version = "0.1.0" | |
[[ArgCheck]] | |
deps = ["Random", "Test"] | |
git-tree-sha1 = "9e3bff61bc46d3420d903b53ad07f85325fddc28" | |
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197" |
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
using OrdinaryDiffEq, DynamicHMC, TransformVariables, LogDensityProblems, MCMCDiagnostics, | |
Parameters, Distributions, LinearAlgebra | |
struct BayesianODEProblem{F, U, S, T, P, N, D} | |
f::F # ODE | |
u::U # initial value | |
timespan::S # timespan as a tuple | |
timepoints::T # evaluated at these points | |
logprior::P # callable, return the log prior of parameters | |
noise::N # a noise distribution for observations |
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
#!/usr/bin/env julia | |
###################################################################### | |
# Overwrite REQUIRE using dependency information from Project.toml. | |
# | |
# Call from the root of the package repository. | |
# | |
# Has some basic sanity checks, but **use at your own risk**, `REQUIRE` | |
# will be overwritten. | |
# | |
# The purpose of this script is to appease attobot, until |
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
# define an iterator with unknown type and length | |
struct MyItr N::Int end | |
Base.IteratorSize(::Type{MyItr}) = Base.SizeUnknown() | |
Base.IteratorEltype(::Type{MyItr}) = Base.EltypeUnknown() | |
function Base.iterate(itr::MyItr, state = 1) | |
if state > itr.N | |
nothing | |
else | |
val = state == 200 ? missing : state | |
(val, state + 1) |
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
# DiffEq tools | |
using DiffEqBayes, OrdinaryDiffEq, ParameterizedFunctions, RecursiveArrayTools | |
# clone from github.com/tpapp | |
using DynamicHMC, MCMCDiagnostics, DiffWrappers, ContinuousTransformations | |
using Parameters, Distributions, Optim | |
f1 = @ode_def_nohes LotkaVolterraTest1 begin | |
dx = a*x - b*x*y |
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
# see https://discourse.julialang.org/t/vector-of-upper-triangle/7764 | |
function vec_triu(M::AbstractMatrix{T}) where T | |
m, n = size(M) | |
m == n || throw(error("not square")) | |
l = n*(n+1) ÷ 2 | |
v = Vector{T}(l) | |
k = 0 | |
for i in 1:n | |
v[k + (1:i)] .= M[1:i, i] |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> | |
<!-- Created by htmlize-1.51 in inline-css mode. --> | |
<html> | |
<head> | |
<title>*scratch*</title> | |
</head> | |
<body style="color: #262626; background-color: #ded6c5;"> | |
<pre> | |
<span style="color: #008b45;">;; </span><span style="color: #008b45;">This buffer is for text that is not saved, and for Lisp evaluation. | |
</span><span style="color: #008b45;">;; </span><span style="color: #008b45;">To create a file, visit it with <open> and enter text in its buffer. |
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
###################################################################### | |
# context: reading UInt8 lines from a gzipped stream | |
# - the real dataset has about 5e10 lines, this is a self-contaned MWE | |
# - the real dataset lines are then processed, this MEW is just about optimizing reading | |
# - line length can be bounded (relevant for buffered reading) | |
###################################################################### | |
using CodecZlib | |
""" |
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
# consistent random numbers | |
srand(UInt32[0xfd909253, 0x7859c364, 0x7cd42419, 0x4c06a3b6]) | |
""" | |
err(x, [prec]) | |
Return two values, which are the log2 relative errors for calculating | |
`log1p(x)`, using `Base.log1p` and `Base.Math.JuliaLibm.log1p`. | |
The errors are calculated by compating to `BigFloat` calculations with the given |
NewerOlder