Skip to content

Instantly share code, notes, and snippets.

View information_bottleneck.py
from pylab import *
import scipy
from scipy import stats
from numba import vectorize, guvectorize, float64, jit, njit
@guvectorize(['void(float64[:], float64[:], float64[:])'],
'(i),(i)->()',
nopython=True
)
@mhlr
mhlr / init.el
Created Feb 14, 2016 — forked from lispnik/init.el
~/.emacs.d/init.el
View init.el
(if window-system
(tool-bar-mode -1)
(menu-bar-mode -1))
(when (eq window-system 'ns)
(add-to-list 'default-frame-alist '(height . 80))
(add-to-list 'default-frame-alist '(width . 132)))
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
@mhlr
mhlr / proto-demo.py
Last active Dec 26, 2020
Enabling delegation / prototypal inheritance / instance based programming in Python
View proto-demo.py
from proto import Proto, ProtoMeta
__metaclass__ = ProtoMeta
class A:
x = "This is X"
def getY(self):
return self._y
class B:
_y = "This is Y"
@mhlr
mhlr / zipf.R
Last active Jan 10, 2017
generate Zipf distributed data as described in http://arxiv.org/abs/1407.7135
View zipf.R
# gnerate Zipf distributed data as described in
# http://arxiv.org/abs/1407.7135
# Zipf's law arises naturally in structured, high-dimensional data
# Laurence Aitchison, Nicola Corradi, Peter E. Latham
n <- 2**22
k <- 20
b <- rnorm(k, 1, 0.2)
data <- replicate(n, {z <- runif(1)
p <- (z^b) / (z^b + (1-z)^b)