Skip to content

Instantly share code, notes, and snippets.

View theogf's full-sized avatar
😶‍🌫️

Théo Galy-Fajou theogf

😶‍🌫️
View GitHub Profile
@theogf
theogf / TestInterface.jl
Created December 20, 2021 16:18
Saved version of the old tests involving AbstractGPs and GPLikelihoods. To be moved to AbstractGPs or ApproximateGPs
module TestInterface
using Random
using Test
function test_interface(
rng::AbstractRNG, lik, x::AbstractVector; functor_args=()
)
gp = GP(kernel)
lgp = LatentGP(gp, lik, 1e-5)
@theogf
theogf / kernel_functions_with_tullio.jl
Created November 5, 2021 10:10
Test Tullio with Kernel Functions
using Tullio
using Distances
using LinearAlgebra
using BenchmarkTools
using CUDA, CUDAKernels, KernelAbstractions
using Functors
using KernelFunctions
using Test
using Functors
@theogf
theogf / Project.toml
Last active October 19, 2021 14:13
Benchmarking of Tullio and Distances.jl
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CUDAKernels = "72cfdca4-0801-4ab0-bf6a-d52aa10adc57"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
KernelFunctions = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Tullio = "bc48ee85-29a4-5162-ae0b-a64e1601d4bc"
@theogf
theogf / mondrian.jl
Last active March 16, 2021 09:03
Sample code for generating a Mondrian process and plotting it
using CairoMakie
# using Animations
using Distributions
using Random
using AbstractTrees
CairoMakie.activate!()
mutable struct Partition
x
y
using StatsFuns
function h(x::AbstractVector, v::AbstractVector, y::AbstractVector, ν::AbstractVector, ϵ::Real, c)
dot(v, ν) - ϵ * logsumexp((v - c.(Ref(x), y)) ./ ϵ .+ log.(ν)) - ϵ
end
function h(x::AbstractVector, v::AbstractVector, y::AbstractVector, ν::AbstractVector, ϵ::Int, c)
ϵ == 0 || error("ϵ has to be 0")
dot(v,ν) + mininum(c.(Ref(x), y) .- v)
end
@theogf
theogf / obs_crash.jl
Created September 22, 2020 09:57
Code for segfault when using observables
using Makie
using AbstractPlotting.MakieLayout
using OnlineStats
t = Node(0)
function foo()
scene, layout = layoutscene()
axis = layout[1,1] = LAxis(scene)
t = Node(0)
it = lift(t, init = MovingWindow(10, Float32)) do t
@theogf
theogf / compare_block_diagonal.jl
Created September 15, 2020 12:12
Comparing how to make diagonal block matrices
using BlockDiagonals
using StatsBase
using BenchmarkTools
using Test
D = 2000
N = 100
K = 20
G = rand(D, N)
X = rand(D, N)
indices = vcat(1, sort(sample(2:D-1, K-1, replace = false)), D+1)
using HTTP
using Dates
using Printf
using JSON
using DataFrames
using FileIO
using CSV
work_location = (52.516747,13.323553)
@theogf
theogf / sinkhorn.jl
Created May 9, 2020 20:12
Implementation of the sinkhorn algorithm
using Makie
using MakieLayout
using LinearAlgebra, Distances
using Distributions
α = MixtureModel([Normal(0.2, 0.05), Normal(0.6, 0.06), Normal(0.8, 0.04)], [0.3, 0.5, 0.2])
# β = Normal(0.3, 0.09)
β = Laplace(0.5, 0.1)
using Distributions
using Plots; pyplot()
using ForwardDiff
using LaTeXStrings
λ = 3.0
μ = 2.0
s = 0.8
# α = Exponential(λ) # Measure alpha the starting point
α = Laplace(μ, s + 1.0)