Skip to content

Instantly share code, notes, and snippets.

View mschauer's full-sized avatar

Moritz Schauer mschauer

View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@MikeInnes
MikeInnes / startup.jl
Last active February 5, 2023 12:54
Some useful macros for Julia
# Repeat an operation n times, e.g.
# @dotimes 100 println("hi")
macro dotimes(n, body)
quote
for i = 1:$(esc(n))
$(esc(body))
end
end
end
@rasmusab
rasmusab / significance_test.R
Last active June 10, 2020 21:01
A Significantly Improved Significance Test! Not! (More context in this blogpost: http://www.sumsar.net/blog/2014/02/a-significantly-improved-test/)
# Test of Significance, takes the same arguments as t.test() .
signif.test <- function(x, ...) {
p <- t.test(x, ...)$p.value
# List of p excuses retrieved from http://mchankins.wordpress.com/2013/04/21/still-not-significant-2/
p_excuses <- c(
"(barely) not statistically significant <p>",
"a barely detectable statistically significant difference <p>",
"a borderline significant trend <p>",
"a certain trend toward significance <p>",
@0xjac
0xjac / private_fork.md
Last active July 23, 2024 09:52
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@cormullion
cormullion / animated-hypotrochoids.jl
Created May 11, 2017 09:14
Animated hypotrochoids
#!/usr/bin/env julia
using Luxor
function makerandomepitrochoid(n)
hlist = []
plist = []
for i in 1:n
R = 20
r = rand(30:3:91)
@vankesteren
vankesteren / Adamopt.jl
Last active June 22, 2024 08:00
Julia implementation of Adam optimizer
module Adamopt
# This is a module implementing vanilla Adam (https://arxiv.org/abs/1412.6980).
export Adam, step!
# Struct containing all necessary info
mutable struct Adam
theta::AbstractArray{Float64} # Parameter array
loss::Function # Loss function
grad::Function # Gradient function
@mschauer
mschauer / bffg.jl
Last active April 13, 2020 14:36
Reference implementation of backwards filtering, forward guiding with https://arxiv.org/abs/1712.03807
using LinearAlgebra
using Random
using GaussianDistributions
using GaussianDistributions: logpdf
pair(u) = u[1], u[2]
pair(p::Gaussian) = p.μ, p.Σ
skiplast(r) = r[1:end-1]
# time grid
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mschauer
mschauer / georgia.jl
Last active May 20, 2022 16:03
Will Georgia become blue (Brownian semimartingale model for vote difference vs percentage)
# 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
@mschauer
mschauer / gist:517b1b3d8eb8301823864ba67bd67f4d
Last active October 22, 2022 22:16
Precision Brownian motion
d = 100
ts_ = range(0, 1, length=d+1)[2:end]
Γ = SymTridiagonal([2.0ones(d-1); 1.0], -ones(d-1))/ts_[1]
# Note the covariance matrix of B.M is
ts = range(0, 1, length=d+1)[2:end]
Γ0 = inv([min(i,j) for i in ts_, j in ts_])
@test norm(Γ0 - Γ) < 1e-7