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 | |
from sympy import * | |
from sympy.parsing.sympy_parser import parse_expr | |
def newton(f, x0, eps): | |
x = Symbol('x') | |
sym_f = parse_expr(f) | |
f = lambdify(x, sym_f) | |
df = lambdify(x, diff(sym_f, x)) | |
while 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
import numpy as np | |
def gauss(A, B): | |
n = len(A) | |
def argmax(A): | |
i, m = 0, A[0] | |
for j, a in enumerate(A): | |
if a > m: |
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 datetime | |
import numpy as np | |
from scipy.interpolate import InterpolatedUnivariateSpline | |
if __name__ == '__main__': | |
# days elapsed from meeting to first copulation | |
xi = np.array([2*7, 2*30]) | |
# days elapsed from meeting to breakup | |
yi = np.array([3*7, 6*30]) | |
s = InterpolatedUnivariateSpline(xi, yi, k=xi.shape[0] - 1) |