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) |
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 AdvancedMH | |
| using Distributions | |
| using Random | |
| using MCMCChains | |
| using StructArrays | |
| struct MvWiener{Tu0,Ttrange} <: ContinuousMatrixDistribution | |
| u0::Tu0 | |
| trange::Ttrange | |
| end |
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 LinearAlgebra, Test, Random, Statistics | |
| outer(x) = x*x' | |
| lchol(x) = cholesky(Symmetric(x)).L | |
| Random.seed!(1) | |
| # dimensions | |
| n = 10 # observed | |
| p = 5 # latent | |
| # parameters |
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 StaticArrays | |
| struct EulerMaruyama! | |
| end | |
| """ | |
| tangent!(du, u, dz, P) | |
| """ |
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 GitHub, JSON | |
| #myauth = GitHub.authenticate(ENV["GITHUB_AUTH"]) | |
| gist_json(fn; description="$fn", public=true) = JSON.parse( | |
| """ | |
| { | |
| "description": "$description", | |
| "public": $public, | |
| "files": { |
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
| function mappairreduce(r, f, itr, dec) | |
| ϕ = iterate(itr) | |
| if ϕ === nothing | |
| return dec | |
| end | |
| xlast, state = ϕ | |
| while true | |
| ϕ = iterate(itr, state) | |
| if ϕ === nothing | |
| return dec |
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 Makie | |
| using Colors | |
| n = 100 | |
| f(x) = 0.5 .*reim(((x[1] + x[2]*im)/33)^2) | |
| function f2(x) | |
| 0.5.*abs(2*(x[1] + x[2]*im)/1089) | |
| end | |
| #f(x) = (x[1],x[2]) | |
| #f2(x) = 1.0 |