Skip to content

Instantly share code, notes, and snippets.

View neftlon's full-sized avatar
🦆

Johannes Spies neftlon

🦆
View GitHub Profile
@neftlon
neftlon / elo.ipynb
Created April 29, 2024 17:03
Elo ranking scheme
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neftlon
neftlon / vae.ipynb
Created March 18, 2024 16:12
VAE for MNIST
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neftlon
neftlon / fourier.ipynb
Created March 7, 2024 23:25
Experiments with Monte-Carlo approximations, Taylor series, and Fourier transforms of distributions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np, itertools, functools, operator
def matrix_exp(A, num_iters=100):
inv_facs = itertools.accumulate(range(1,num_iters+1), operator.mul, initial=1)
As = itertools.accumulate(range(num_iters), lambda Ap, _: np.dot(Ap, A), initial=A)
return sum(1. / inv_fac * A for inv_fac, A in zip(inv_facs, As))
@neftlon
neftlon / miniautograd.rs
Created March 21, 2023 10:26
mini autograd engine in Rust
use std::{
cell::RefCell,
ops::{Add, Mul, Neg},
rc::Rc,
};
#[derive(Debug, Clone)]
struct Var {
inner: VarInnerRef,
}
@neftlon
neftlon / a3m2neff.sh
Created December 12, 2022 14:50
extract Neff scores from mmseqs2
#!/usr/bin/bash
# This is a short script that uses a NON-STANDARD version of mmseqs2
# to extract Neff scores from a profile.
#
# Please set the MMSEQS and REFORMAT enviroment variables to point to the
# respective executables! Otherwise, this script will try to use default
# parameters and fail ungracefully.
#
# This script takes MSAs in .a3m format as input and produces a file
@neftlon
neftlon / random_file_picker.py
Last active November 25, 2022 08:25
pick k random files from a directory that lay within a given size range
#!/usr/bin/env python3
"""pick k random files from a directory that lay within a given size range"""
import os
import random
import sys
if len(sys.argv) != 2:
print(f"usage: {sys.argv[0]} dirname")
@neftlon
neftlon / kmp.cpp
Created February 21, 2020 22:24
Implementation of the Wikipedia-version of the KMP string matching algorithm in C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int ArgCount, char **Args)
{
char *Pattern = "ababcabab";
char *Text = "abababcbababcababcab";
size_t PatternLength = strlen(Pattern);