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 Soss: logdensity, xform, ConditionalModel | |
using ZigZagBoomerang | |
using ForwardDiff | |
using ForwardDiff: gradient! | |
using LinearAlgebra | |
using SparseArrays | |
using StructArrays | |
using TransformVariables |
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
xnew = sample(A[x, :]) | |
struct TransitionKernel | |
A::Matrix | |
end | |
(kappa::TransitionKernel)(x) = kappa.A[x, :] | |
A = [0.5 0.5 0 | |
0 0.3 0.7 |
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
export basemeasure | |
import MeasureTheory | |
function MeasureTheory.basemeasure(c::ConditionalModel{A,B,M}, x=NamedTuple()) where {A,B,M} | |
_basemeasure(M, Model(c), argvals(c), observations(c), x) | |
end | |
export sourceBasemeasure |
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 MeasureTheory | |
using Random | |
using Test | |
n = 30 | |
ρ = rand(n) | |
struct PlusBernoulli{S,T} <: MeasureTheory.AbstractMeasure | |
x::S |
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 ZigZagBoomerang | |
using Distributions | |
using SparseArrays | |
using LinearAlgebra | |
using Random | |
Random.seed!(1) | |
# Million data points, 5 parameters + intercept | |
N = 1000000 | |
k = 5; | |
X = randn(N,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 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 |