Skip to content

Instantly share code, notes, and snippets.

View tpoisot's full-sized avatar

Timothée Poisot tpoisot

View GitHub Profile
using Zygote
using Distributions
lm(x, m, b) = m .* x .+ b
x = rand(Uniform(-2, 2), 100)
ε = rand(Normal(0.0, 0.05), length(x))
p₀ = [-1.2, 0.05]
y = lm(x + ε, p₀...)
We can't make this file beautiful and searchable because it's too large.
Longitude,Latitude,Presence,Annual Mean Temperature,Mean Diurnal Range,Isothermality,Temperature Seasonality,Max Temperature of Warmest Month,Min Temperature of Coldest Month,Temperature Annual Range,Mean Temperature of Wettest Quarter,Mean Temperature of Driest Quarter,Mean Temperature of Warmest Quarter,Mean Temperature of Coldest Quarter,Annual Precipitation,Precipitation of Wettest Month,Precipitation of Driest Month,Precipitation Seasonality,Precipitation of Wettest Quarter,Precipitation of Driest Quarter,Precipitation of Warmest Quarter,Precipitation of Coldest Quarter
4.645833333333333,52.354166666666664,0,9.8115,6.8223333,32.80599,519.0232,21.28,0.484,20.796001,10.71,8.669333,16.204666,3.662,835.0,99.0,45.0,25.123003,280.0,156.0,202.0,197.0
4.645833333333333,52.979166666666664,0,9.9,4.922222,26.727,493.6818,19.9,1.4833333,18.416666,11.4388895,10.944445,16.116667,4.2055554,813.0,103.0,46.0,29.996643,295.0,149.0,212.0,175.0
4.854166666666667,61.0625,0,7.3601193,3.9666667,24.604933,464.8009,16.164286,0.0
@tpoisot
tpoisot / covidqc.jl
Last active September 17, 2022 01:22
COVID data Québec
using DataFrames
using DataFramesMeta
using CSV: CSV
using CairoMakie
using AlgebraOfGraphics
using Dates
using Downloads
CairoMakie.activate!(; px_per_unit=2)
@tpoisot
tpoisot / color.jl
Created February 29, 2020 17:51
colormaps with equal luminance
using Pkg
Pkg.activate(".")
using Colors
using Mustache
using Plots
using Clustering
luma(color) = luma(convert(RGB, color))
luma(color::T) where {T <: RGB} = 0.299color.r + 0.587color.g + 0.114color.b
@tpoisot
tpoisot / turing.jl
Last active February 13, 2020 02:49
import Pkg
Pkg.activate(".")
using Turing
using StatsPlots
using StatsBase
import CSV
d_orig = CSV.read("ls.csv")
d = d_orig[d_orig.P .> 0,:]
@tpoisot
tpoisot / frrg.jl
Created August 2, 2018 18:26
force directed layout
# http://faculty.washington.edu/joelross/courses/archive/s13/cs261/lab/k/
using EcologicalNetworks
using Plots
N = simplify(nz_stream_foodweb()[1])
mutable struct NodePosition
x::Float64
y::Float64
@tpoisot
tpoisot / wong.jl
Created June 1, 2018 16:27
Wong 2011 color blind friendly palette
cbfp = Dict(
:orange => "#e69f00",
:sky_blue => "#56b4e9",
:bluish_green => "#009e73",
:yellow => "#f0e442",
:blue => "#0072b2",
:vermillion => "#d55e00",
:reddish_purple => "#cc79a7"
)
using Plots
λ = 1.07
K = 50.0
a = 0.06
n = 1.0
ΔN(Nt,Pt) = λ*Nt*exp((1-Nt/K)-a*Pt)
ΔP(Nt,Pt) = n*Nt*(1-exp(-a*Pt))
@tpoisot
tpoisot / isoclines.jl
Created October 23, 2017 15:38
Isoclines, quiver, etc
using Plots
using Iterators
pyplot()
function dn(n1, n2; α=[1.0 0.0; 0.0 1.0], r1=1.0, r2=1.0)
dn1 = n1*(r1-α[1,1]*n1-α[1,2]*n2)
dn2 = n2*(r2-α[2,2]*n2-α[2,1]*n1)
return dn1, dn2
end
@tpoisot
tpoisot / quiver_plot_popdyn.jl
Created July 14, 2017 20:42
Quiver plot // julia // population dynamics
using Plots
pyplot()
"""
Derivatives
prey, predator, growth, comp, conversion, predation, mortality
"""
function ṅ(x, y, r, q, α, β, δ)
ẋ = r*x - q*x^2 - β*y*x
ẏ = α*β*y*x - δ*y