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
def derivative(f, x): | |
h = 0.00000001 | |
return (f(x+h) - f(x)) / h | |
x=10 | |
approx_derivative = derivative(lambda x: 1/x, x) | |
actual = -1/(x*x) | |
print('approx:', approx_derivative,', actual:', actual) |
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 ecdf(sample): | |
n = len(sample) | |
x = np.sort(sample) | |
y = np.arange(1, len(x)+1) / n | |
return x, y |
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
def fib_to(n): | |
fibs = [0, 1] | |
for i in range(2, n+1): | |
fibs.append(fibs[-1] + fibs[-2]) | |
return fibs | |
print(fib_to(40000)[33399]) |
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
select GETDATE() --2021-09-01 19:35:22 | |
select time_slice(getdate()::timestamp_ntz, 1, 'HOUR') --2021-09-01 19:00:00 |