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
# METHOD 1 vs. METHOD 2 | |
# test sample | |
l = [[1,2,3],[4,5,6], [7], [8,9]]*99 | |
# METHOD 1: List Comprehension (slower) | |
flat_list = [item for sublist in l for item in sublist] | |
# tested in .ipynb with %timeit | |
# METHOD 2: itertools chain (~2x faster) |
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
void cubic_solver(double A, double B, double C, double D, double *roots) { | |
double xN, yN; // yN = f(xN) | |
double del; | |
double h; | |
double theta; | |
double alpha, beta, gamma; // roots | |
xN = -B/(3*A); | |
yN = (A*xN*xN*xN) + (B*xN*xN) + (C*xN) + D; | |
del = sqrt( (B*B - 3*A*C) / ((9*A*A)) ); |
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 matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
from matplotlib import cm | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
#uncomment below if using Jupyter | |
#%config InlineBackend.figure_format = 'retina' | |
# get data |
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 numpy as np | |
import pandas as pd | |
import tensorflow as tf | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
#uncomment below if using Jupyter | |
#%config InlineBackend.figure_format = 'retina' | |
# get data | |
df = pd.read_csv('../some/data/path') |
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 tensorflow as tf | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# setup dummy data | |
n = 1000 | |
x = np.random.normal(0, 0.55, n) | |
y = 0.1*x + 0.3 + np.random.normal(0, 0.03, n) #want to find a=0.1 and b=0.3 | |
plt.plot(x, y) | |
plt.show() |