Skip to content

Instantly share code, notes, and snippets.

View mschauer's full-sized avatar

Moritz Schauer mschauer

View GitHub Profile
@jiahao
jiahao / llama2.jl
Last active August 2, 2023 08:35
NOTE 2023-07-30: This gist is deprecated in favor of https://github.com/rai-llc/LanguageModels.jl . llama2.jl is a port of @karpathy's llama2.c to Julia.
# A port of https://github.com/karpathy/llama2.c/blob/master/run.c
# to Julia.
# Jiahao Chen <[email protected]> 2023-07-29
#
# MIT License: see full text at https://opensource.org/license/mit/
#
using LinearAlgebra
using LogExpFunctions
@RaphaelS1
RaphaelS1 / Documentation.yml
Last active September 19, 2022 05:35
Workflow to check if all objects in Julia package documented as expected.
name: Documentation
on:
push:
branches:
- main
- master
tags: '*'
pull_request:
@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
@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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@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
@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)
@0xjac
0xjac / private_fork.md
Last active November 15, 2024 13:06
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 [email protected]:usi-systems/easytrace.git

@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>",