Skip to content

Instantly share code, notes, and snippets.

@Orpheon
Created December 31, 2013 21:31
Show Gist options
  • Select an option

  • Save Orpheon/8202415 to your computer and use it in GitHub Desktop.

Select an option

Save Orpheon/8202415 to your computer and use it in GitHub Desktop.
from __future__ import division, print_function
from scipy import stats
import math
x_file = open("X", "r")
x_data = x_file.read().split()
x_file.close()
y_file = open("Y", "r")
y_data = y_file.read().split()
y_file.close()
x = [int(i) for i in x_data]
y = [int(i) for i in y_data]
log_y = [math.log(float(i)) for i in y_data]
slope, intercept, r_value, p_value, std_err = stats.linregress(x,log_y)
print(slope, intercept, r_value, p_value, std_err)
output = open("output", "w")
s = ""
for i in x:
s += str(math.exp(slope*i + intercept))+"\n"
output.write(s)
output.close()
output = open("log_output", "w")
s = ""
for i in x:
s += str(slope*i + intercept)+"\n"
output.write(s)
output.close()
output = open("log_y", "w")
s = ""
for i in log_y:
s += str(i)+"\n"
output.write(s)
output.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment