-
Notifications
You must be signed in to change notification settings - Fork 26
/
mcmc
executable file
·36 lines (31 loc) · 900 Bytes
/
mcmc
1
2
3
4
5
6
7
8
9
10
11
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
#!/usr/bin/env python3
import sys
import numpy as np
import json
import pandas as pd
import os
def model(a, b, c, d):
a = int(a)
b = int(b)
c = int(c)
d = int(d)
x = np.linspace(0, 1, 50)
return np.random.poisson(
a * (0.5 * np.sin(2.0 * np.pi * x) + 1.0) +\
b * (0.5 * np.sin(4.0 * np.pi * x) + 1.0) +\
c * (0.5 * np.sin(6.0 * np.pi * x) + 1.0) +\
d * (0.5 * np.sin(8.0 * np.pi * x) + 1.0))
if __name__ == '__main__':
if len(sys.argv) != 2:
sys.exit("Usage: beam input_file")
json_input = sys.argv[1]
with open(json_input, 'r') as fd:
inputs = json.load(fd)
a = inputs['a']
b = inputs['b']
c = inputs['c']
d = inputs['d']
outfile = inputs['outfile']
data = pd.DataFrame({"Values": model(a, b, c, d)})
directory="."
data.to_csv(os.path.join(directory, outfile), index=False)