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 IterativeSolvers | |
| using LinearAlgebra | |
| A = rand(-10:10, 16, 16) + 5*LinearAlgebra.I | |
| x = rand(-10:10, 16) | |
| b = A*x | |
| y = idrs(BigFloat.(A), BigFloat.(b), s=4, tol=1e-100, maxiter=100, verbose=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 Distributions, Statistics, LinearAlgebra | |
| ## simulate sample trajectory | |
| μ = [1.0, 0.0] | |
| Σ = [0.5 0.0 | |
| 0.0 0.5] | |
| x0 = rand(MultivariateNormal(μ, Σ)) #start point | |
| β = [0.0, 0.0] |
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
| # Fit a Brownian motion with drift to and scale to | |
| # Georgia election data: | |
| # fraction of total count of votes vs difference in votes | |
| data = [0.9222672139181572 103896.10389610389 | |
| 0.9267802009311443 87662.33766233765 | |
| 0.9277217593727027 85714.28571428571 | |
| 0.9285683655966674 83116.88311688312 | |
| 0.9299797843665768 79220.77922077922 | |
| 0.9310169076206811 78571.42857142857 |
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
| #= | |
| Newborn babies are more likely to be boys than girls. | |
| A random sample found 13 173 boys were born among 25 468 | |
| newborn children. Population: All children born that time period. Alternatively, | |
| the unknown p could be the unknown probability. | |
| =# | |
| b = 13173 | |
| n = 25486 |
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 GaussianDistributions | |
| using GaussianDistributions: correct, ⊕ | |
| using LinearAlgebra | |
| using Statistics | |
| lchol(a) = cholesky(a).L | |
| llikelihood(yres, S) = GaussianDistributions.logpdf(Gaussian(zero(yres), Symmetric(S)), yres) | |
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
| # Linear state space system forward filtering backward sampling with Zygote | |
| using LinearAlgebra | |
| using GaussianDistributions | |
| using GaussianDistributions: ⊕, logpdf | |
| using StaticArrays | |
| using Statistics | |
| using Zygote |
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 ForwardDiff: derivative | |
| partiali(f, x, i) = ForwardDiff.partials(f([Dual{}(x[j], 1.0*(i==j)) for j in eachindex(x)]))[] | |
| struct ∂{k, F} <: Function | |
| f::F | |
| ∂{k}(f::F) where {k, F} = new{k, F}(f) | |
| end | |
| function (pd::∂{k})(args...) where {k} |
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 | |
| using Makie | |
| using Random | |
| g(x, α, β) = pdf(Gamma(α, 1/β), x) | |
| lg(x, α, β) = logpdf(Gamma(α, 1/β), x) | |
| Random.seed!(1) | |
| T = 100 |
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
| # ] add https://github.com/mschauer/BridgeSPDE.jl | |
| # will run in the parent directory | |
| # of the script location and create output folder there | |
| cd(joinpath(@__DIR__, "..")) | |
| using SparseArrays | |
| using BridgeSPDE | |
| using FileIO |
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
| # Zig zag and Boomerang reference implementation | |
| """ | |
| poisson_time(a,b,u) | |
| obtaining waiting time for inhomogeneous Poisson Process | |
| with rate of the form λ(t) = (a + b*t)^+, `a`,`b` ∈ R, `u` uniform random variable | |
| """ | |
| function poisson_time(a,b,u) | |
| if b > 0 | |
| if a < 0 |