Skip to content

Instantly share code, notes, and snippets.

View breuderink's full-sized avatar

Boris Reuderink breuderink

View GitHub Profile
Warning: A new session was created in folder 'session_1'
> In session.session>session.instance at 79
In abstract_node.get_data_dir at 40
In abstract_node.get_full_dir at 36
In abstract_node.initialize at 35
In abstract_node.run at 88
In meeg at 17
Error using datahash.DataHash>CoreHash (line 319)
Java exception occurred:
java.lang.OutOfMemoryError: Java heap space
@breuderink
breuderink / gen.py
Created March 12, 2015 18:45
Visualize simple state space model
import pylab as plt
import numpy as np
def gen(x, evolve, project, n=1000, sigma=.1):
y = []
for i in xrange(int(n)):
y.append(np.dot(project, x))
x = np.dot(evolve, x)
x = np.clip(x, -100, 100)
x += np.random.randn(*x.shape) * sigma
@breuderink
breuderink / halton.go
Created April 24, 2017 19:59
halton.go
package main
import (
"fmt"
)
func main() {
// Implementation of baseline fixed-point algorithm in [1].
//
// [1] Kolář, Miroslav, and Seamus F. O'Shea. "Fast, portable, and
@breuderink
breuderink / most_normal.py
Last active September 19, 2017 18:51
The hunt for the most normal scrambler for SORM features.
from scipy import linalg, stats
import numpy as np
from functools import reduce
N = 16
def eval_scrambler(pat, reps=1):
pat = np.atleast_1d(pat)
D = np.diag(np.where(pat==1, -1, 1))
H = linalg.hadamard(pat.size)
@breuderink
breuderink / tdc.c
Created September 22, 2017 10:53
Linear TD with gradient correction
// [1] Sutton, Richard S., et al. "Fast gradient-descent methods for
// temporal-difference learning with linear function approximation."
// Proceedings of the 26th Annual International Conference on Machine
// Learning. ACM, 2009.
#define TDC_NFEAT 4
typedef struct {
float gamma;
float theta[TDC_NFEAT], w[TDC_NFEAT];
@breuderink
breuderink / Makefile
Created October 3, 2017 11:29
Calling C from Python
libsum.so: sum.c
cc -shared -o libsum.so sum.c
@breuderink
breuderink / cartpolev1.tsv
Last active February 23, 2018 21:17
Dump SARS from AI Gym
-0.044 -0.15 0.013 0.28 1 1 -0.047 0.046 0.018 -0.013
-0.047 0.046 0.018 -0.013 1 1 -0.046 0.24 0.018 -0.3
-0.046 0.24 0.018 -0.3 0 1 -0.041 0.046 0.012 -0.0013
-0.041 0.046 0.012 -0.0013 1 1 -0.04 0.24 0.012 -0.29
-0.04 0.24 0.012 -0.29 1 1 -0.035 0.44 0.0063 -0.58
-0.035 0.44 0.0063 -0.58 1 1 -0.026 0.63 -0.0053 -0.87
-0.026 0.63 -0.0053 -0.87 1 1 -0.014 0.83 -0.023 -1.2
-0.014 0.83 -0.023 -1.2 1 1 0.0027 1 -0.046 -1.5
0.0027 1 -0.046 -1.5 1 1 0.023 1.2 -0.075 -1.8
0.023 1.2 -0.075 -1.8 1 1 0.047 1.4 -0.11 -2.1
@breuderink
breuderink / idw.c
Last active July 7, 2019 14:41
Inverse distance weighting
#include <assert.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
typedef struct {
size_t size[2];
size_t stride[2];
float *elements;
@breuderink
breuderink / expander.c
Last active September 9, 2019 14:17
expander graph
// Generate expander graph. See https://mathoverflow.net/q/124714.
// cc expander.c -o expander && ./expander | \
// neato -Tpng -o expander.png -Goverlap=false -Gsplines=true
// From https://rosettacode.org/wiki/Modular_inverse#C
int mod_inv(int a, int b) {
int b0 = b, t, q;
int x0 = 0, x1 = 1;
if (b == 1) return 1;
while (a > 1) {
@breuderink
breuderink / fx.c
Created November 30, 2019 20:19
SORF
#include "fx.h"
#include <stddef.h>
#include <stdint.h>
#include <math.h>
#include <assert.h>
void static inline wht_butterfly(float * const s, float * const d) {
float temp = *s;
*s += *d;
*d = temp - *d;