This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def lag(x, n=0): | |
observed = np.isnan(x) == False | |
observed[0] = True | |
offsets = np.flatnonzero(observed) | |
return offsets[np.maximum(np.cumsum(observed) - 1 - n, 0)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM jupyter/datascience-notebook | |
USER root | |
RUN apt-get update && apt-get install -yq graphviz | |
USER $NB_USER | |
RUN pip install lingam graphviz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libsum.so: sum.c | |
cc -shared -o libsum.so sum.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [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]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder