Skip to content

Instantly share code, notes, and snippets.

View larsbratholm's full-sized avatar

Lars Andersen Bratholm larsbratholm

View GitHub Profile
4
H 1.01361 -0.43872 0.05166
H -0.37629 -0.59645 0.04850
H 1.62350 -1.33635 0.06931
H -0.80859 -1.59316 0.06357
3
H -0.65849 1.79875 0.00662
H 0.73147 1.95418 0.00966
H -1.29266 2.67914 -0.01097
2
H 2.96821 1.08475 0.03403
H 3.24493 2.05794 0.01754
20
Energy: -11.4541449
C -1.20080 0.52014 0.02618
C -0.65849 1.79875 0.00662
C 0.73147 1.95418 0.00966
C 1.58002 0.83735 0.03236
C 1.01361 -0.43872 0.05166
C -0.37629 -0.59645 0.04850
C 3.99063 0.15254 0.05602
C 5.34795 0.81013 0.04860
@larsbratholm
larsbratholm / mae_ci.py
Last active March 8, 2020 11:05
Calculate 95% confidence interval for rapported MAE. The data is assumed to follow a laplacian distribution.
"""
Calculate 95% confidence interval for rapported MAE.
The data is assumed to follow a laplacian distribution.
See https://waset.org/publications/8809/confidence-intervals-for-double-exponential-distribution-a-simulation-approach
for derivation.
"""
import numpy as np
import scipy.stats as ss
@larsbratholm
larsbratholm / jread.py
Created April 9, 2019 11:27
j-coupling reader
def jread(filename, atomnumber):
couplings = np.zeros((atomnumber, atomnumber), dtype=float)
with open(filename) as f:
skip = True
for line in f:
if "Total nuclear spin-spin coupling J (Hz):" in line:
skip = False
continue
elif "End of Minotr" in line:
@larsbratholm
larsbratholm / lasso.py
Created March 26, 2019 20:20
Lasso example
import numpy as np
from sklearn.linear_model import Lasso, LinearRegression
# Generate 100 samples of y = x**2 plus some small random error
n = 100
x = np.random.random(100)
y = x**2 + 0.1*np.random.random(n)
# Create [x,x**2] as different features
f = np.asarray([x,x**2]).T
# Train a linear regression model as comparison
@larsbratholm
larsbratholm / lol.py
Created March 14, 2019 13:51
Outer cv osprey
outer_cv = KFold(5, shuffle=True)
for train, test in outer_cv.split(range(n_datapoints)):
for n in [100, 300, 1000, 3000, 10000, 30000, 100000]:
# save file for osprey containing the indices of train[:n]
# save file with test indices to get test errors after finding best params with osprey
@larsbratholm
larsbratholm / get_submatrix.py
Last active March 13, 2019 15:19
Example showing np.ix_
import numpy as np
import copy
K # shape (N,N)
# Create a list with all the indices of the submatrix
idx = np.arange(N-1) + 1
for i in range(N):
# when i==0, idx will be [1,2,3,4...]
# when i==1, idx will become [0,2,3,4...] etc
from simtk import openmm, unit
from simtk.openmm import app
import numpy as np
import sys
# Create an integrator
timestep = 1.0 * unit.femtoseconds
integrator = openmm.VerletIntegrator(timestep)
# Open Amber files