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 pylab import grid, show, savefig, subplots, tight_layout, style | |
import numpy as np | |
style.use('ggplot') | |
def phase_plane(A, x_min=-3, x_max=3, y_min=-3, y_max=3): | |
fig, ax = subplots(1,1, figsize=(5,5), dpi=500) | |
state_vec = np.array( | |
np.meshgrid( | |
np.linspace(x_min, x_max, 1000), | |
np.linspace(y_min, y_max, 1000) |
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
####################################################################### | |
# copied from https://github.com/gillescastel/latex-snippets # | |
####################################################################### | |
global !p | |
texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']] | |
texIgnoreMathZones = ['texMathText'] | |
texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')") |
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 logging | |
import datetime | |
import tensorflow as tf | |
class BatchProfileCallback(tf.keras.callbacks.Callback): | |
""" | |
BatchProfileCallback | |
Log how long a batch takes to run. Monitor potential slow downs. |
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
platform=$(uname -s) | |
arch=$(uname -m) | |
PYTHON_VERSION=3.10 | |
if [[ "$platform" == 'Linux' ]]; then | |
sudo apt install stow tldr | |
curl -sS https://starship.rs/install.sh | sh | |
git clone --depth 1 https://github.com/wbthomason/packer.nvim\ ~/.local/share/nvim/site/pack/packer/start/packer.nvim |
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 os | |
import tensorflow as tf | |
from twilio.rest import Client | |
class SMSCallback(tf.keras.callbacks.Callback): | |
""" | |
SMSCallback | |
Because you are not always standing in front of your computer waiting for |
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
# This is part of the implementation of this paper | |
# https://www.aaai.org/Papers/FLAIRS/1999/FLAIRS99-042.pdf | |
# This was written for MLDB (www.mldb.ai). Not tested for other databases | |
# Conditional entropy $H(Y|X) = -\sum_x{P(x)\sum_y{P(y|x)\log(P(y|x))}}$ | |
from pandas import DataFrame | |
def conditional_entropy(Y, X, table): | |
df = mldb.query(""" | |
SELECT -sum(PX.p_x*A.right) | |
FROM ( |
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 random | |
import numpy as np | |
# http://erikerlandson.github.io/blog/2015/11/20/very-fast-reservoir-sampling/ | |
def fast_reservoir_sampling(file_handle, N=1000000, callable=None): | |
sample = [] | |
if callable is None: | |
callable = lambda x: x | |
j = N |