{{ message }}

Instantly share code, notes, and snippets.

Théo Galy-Fajou theogf

Last active Mar 16, 2021
Sample code for generating a Mondrian process and plotting it
View mondrian.jl
 using CairoMakie # using Animations using Distributions using Random using AbstractTrees CairoMakie.activate!() mutable struct Partition x y
Last active Oct 2, 2020
Compute semidiscrete wasserstein according to https://papers.nips.cc/paper/6566-stochastic-optimization-for-large-scale-optimal-transport.pdf
View semidiscrete.jl
 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
Created Sep 22, 2020
Code for segfault when using observables
View obs_crash.jl
 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
Created Sep 15, 2020
Comparing how to make diagonal block matrices
View compare_block_diagonal.jl
 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)
Created Jun 2, 2020
View transit_grid_berlin.jl
 using HTTP using Dates using Printf using JSON using DataFrames using FileIO using CSV work_location = (52.516747,13.323553)
Created May 9, 2020
Implementation of the sinkhorn algorithm
View sinkhorn.jl
 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)
Last active May 11, 2020
Source file for the animation displayed in : https://twitter.com/theo_gf/status/1258015348420489217
View transform_alpha_to_beta.jl
 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)
Last active Apr 28, 2020
Animation of normalizing flows
View normalizing_flows.jl
 using Distributions using Bijectors using Makie, Colors using Animations p0 = MvNormal(ones(2)) samples = rand(p0, 1) abslim = -7
Last active Mar 31, 2020
View plot_complex.jl
 using Plots; pyplot() N = 100 x = range(-3, 3, length=N) f1(x, y) = begin z = Complex(x, y); abs(z^z); end f2(x, y) = begin z = Complex(x, y); angle(z^z); end surface(x, x, f1.(x, x'), fill_z = f2.(x, x'), clims = (-pi, pi), color = :colorwheel)
Created Mar 24, 2020
Logo Julia Gaussian Processes
View logojuliagps.jl
 using Plots, Colors, Measures using AugmentedGaussianProcesses pyplot() julia_blue = RGB(0.251, 0.388, 0.847) julia_green = RGB(0.22, 0.596, 0.149) julia_purple = RGB(0.584, 0.345, 0.698) julia_red = RGB(0.796, 0.235, 0.2) x = [0.1, 0.2, 0.3]