SPC q q
- quitSPC w /
- split window verticallySPC w
- - split window horizontallySPC 1
- switch to window 1SPC 2
- switch to window 2SPC w d
- delete current windowSPC TAB
- switch to previous bufferSPC b b
- switch buffers
This file contains 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
""" | |
A hilary-endorsing script that loads the predictions from the NYT. | |
""" | |
import requests | |
from dateutil.parser import parse | |
# election forecast link | |
url = "https://intf.nyt.com/newsgraphics/2016/11-08-election-forecast/president.json" | |
req = requests.get(url) |
This file contains 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
function F = funm_randomized(A,fun) | |
%FUNM_RANDOMIZED Evaluate general matrix function using | |
% randomized approximate diagonalization method of Davies (2007). | |
tol = 8*eps(A(1,1)); % Tolerance for single or double precision A. | |
E = randn(size(A)); | |
[V,D] = eig(A + (tol*norm(A,'fro')/norm(E,'fro'))*E); | |
F = V*diag(fun(diag(D)))/V; |
This file contains 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 scipy as sc | |
from scipy.stats import norm | |
N=100 | |
M = 1000 | |
nsamp = sc.zeros(M) | |
for i in range(M): | |
data=sc.randn(N)*0.1 |
This file contains 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 clip | |
def dict_clipper(dictionary): | |
""" | |
Clips all the numeric values of a dictionary so | |
that they lie within [0,1]. | |
It recurses within inner dictionaries, | |
if any. | |
This file contains 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
def tree_to_cherry_tree(A): | |
""" | |
Given the adj matrix of a tree, | |
produces a cherry t-tree that includes it. | |
Arguments: | |
- adj: numpy array or sparse array, the adjacency matrix of the tree. | |
Returns: | |
- new_adj: numpy array or sparse array, the adjacency matrix of the cherry tree. |
This file contains 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
;; -*- mode: emacs-lisp -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Configuration Layers declaration. | |
You should not put any user code in this function besides modifying the variable | |
values." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory |
This file contains 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 jax | |
import jax.numpy as jnp | |
def ent(X): | |
"""Calculates the entropy of a dataset X.""" | |
N, D = X.shape # Get the number of samples and dimensions | |
# Compute pairwise squared distances |