Skip to content

Commit 906617a

Browse files
author
Erik Henning Thiede
committed
First commit, adding the alpha code for the EMUS
package.
1 parent 41b4ef0 commit 906617a

10 files changed

Lines changed: 1213 additions & 0 deletions

LICENSE.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
This code is released under the MIT License
2+
3+
Copyright (c) 2016 Erik Henning Thiede
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-----------
2+
Description
3+
-----------
4+
5+
This is an implementation of the EMUS algorithm for recombining data
6+
from umbrella sampling calculations and other data sources coming from
7+
biased probability densities.
8+
9+
10+
-------------------
11+
Usage and Arguments
12+
-------------------
13+
14+
To be continued....
15+

argparsetest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import argparse
2+
parser = argparse.ArgumentParser()
3+
parser.add_argument("x", type=float, help="the base")
4+
parser.add_argument("y", type=float, help="the exponent")
5+
parser.add_argument("-v", "--verbosity", action="count", default=0)
6+
args = parser.parse_args()
7+
answer = args.x**args.y
8+
if args.verbosity >= 2:
9+
print "Running '{}'".format(__file__)
10+
if args.verbosity >= 1:
11+
print "{}^{} ==".format(args.x, args.y),
12+
print answer

asciiemus.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#########################################################################
2+
# #
3+
# /-/-=/-= #
4+
# // ZX " #
5+
# / /XZX (O) ---, #
6+
# // ZXZX _____`\ #
7+
# / ZXZXZX #
8+
# / ;,ZXZ #
9+
# / :ZX%\ #
10+
# /% : X\ #
11+
# :/: %:X: #
12+
# /%:% %\\ #
13+
# /:%: % \ #
14+
# / :% : \ #
15+
# / :% :%\ #
16+
# /% % \ #
17+
# /%: %: %\ #
18+
# //% : %\ #
19+
# %%%%%%%%%% %% %% / / : : #
20+
# %%%%%%%% %% % %%%% \: #
21+
# %%%%%% : \ #
22+
# %%%% :%:\ #
23+
# % % % \ #
24+
# % %% \ #
25+
# % %%% %%%%%% \ #
26+
# % %%%%%%%% %%%\ #
27+
# % %% %%%%%% %\ #
28+
# % %%%%%%%%%%%%% %%%%\\ #
29+
# %%%%/%%%%%%%%%%%%%%%%%%%%%%% %%%%%%% %%% %%\ #
30+
# / %%%%%%%%% % %% % %%% % %%%%% %%%\ #
31+
# (_____)%%(_____)%%%%%%\ #
32+
# ((_____) ((____) #
33+
# (___) (___) #
34+
# (__) (__) #
35+
# (__) (__) #
36+
# (__) (__) #
37+
# (__) (__) #
38+
# ( ) ( ) V@V #
39+
# ( ) ( ) | #
40+
# ( ) ( ) \ | / / #
41+
# (__ | (___ | \ | / #
42+
# ___( / \ \____ \ |--- \\|// #
43+
# <(____/ \_____(>\_____(> -===-= #
44+
# #
45+
###################### EMUS FINISHED SUCCESSFULLY #######################

autocorrelation.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tools for analyzing the autocorrelation of a time series
4+
"""
5+
import numpy as np
6+
7+
def autocorrfxn(timeseries,lagmax):
8+
ts = np.asarray(timeseries)
9+
ts -= np.average(ts) # Set to mean 0
10+
N = len(timeseries)
11+
corrfxn = np.zeros(lagmax)
12+
for dt in xrange(lagmax):
13+
corrfxn[dt] = (np.dot(timeseries[0:N-dt],timeseries[dt:N])) # sum of ts[t+dt]*ts[t]
14+
corrfxn /= corrfxn[0] # Normalize
15+
return corrfxn
16+
17+
18+
def ipce(timeseries,lagmax=None):
19+
"""
20+
Initial positive correlation time estimator
21+
"""
22+
if lagmax == None:
23+
lagmax = len(timeseries)/2
24+
corrfxn = autocorrfxn(timeseries,lagmax)
25+
i = 0
26+
t = 0
27+
while i < 0.5*lagmax:
28+
gamma = corrfxn[2*i] + corrfxn[2*i+1]
29+
if gamma < 0.0:
30+
print 'stop at ',2*i
31+
break
32+
else:
33+
t += gamma
34+
i += 1
35+
tau = 2*t - 1
36+
std = np.std(timeseries)
37+
mean = np.average(timeseries)
38+
sigma = std * tau / len(timeseries)
39+
return tau, mean, sigma
40+
41+
def icce(timeseries,lagmax=None):
42+
"""
43+
Initial convex correlation time estimator
44+
REWRITE TO BE MORE EFFICIENT!
45+
"""
46+
if lagmax == None:
47+
lagmax = len(timeseries)/2
48+
corrfxn = autocorrfxn(timeseries,lagmax)
49+
t = corrfxn[0] + corrfxn[1]
50+
i = 1
51+
gammapast = t
52+
gamma = corrfxn[2*i] = corrfxn[2*i+1]
53+
while i < 0.5*lagmax:
54+
gammafuture = corrfxn[2*i+2] + corrfxn[2*i+3]
55+
if gamma > 0.5*(gammapast+gammafuture) :
56+
print 'stop at ',2*i
57+
break
58+
else:
59+
t += gamma
60+
gammapast = gamma
61+
gamma = gammafuture
62+
i += 1
63+
tau = 2*t - 1
64+
std = np.std(timeseries)
65+
mean = np.average(timeseries)
66+
sigma = std * tau / len(timeseries)
67+
return tau, mean, sigma
68+

0 commit comments

Comments
 (0)