Hi!
I'm using the algorithm described here to fit Gaussian bell curves to my data.
If I generate my data array with:
x=linspace(1.,100.,100)
data= 17*exp(-((x-10)/3)**2)
everything works fine.
But if I read the data from a text file using
file = open("d:\\test7.txt")
arr=[]
data=[]
def column(matrix,i):
return [row[i] for row in matrix]
for line in file.readlines():
numbers=map(float, line.split())
arr.append(numbers)
data = column(arr,300)
x=linspace(1.,115.,115)
I get the error message:
Traceback (most recent call last):
File "readmatrix.py", line 60, in <module> fit(f, [mu, sigma, height], data)
File "readmatrix.py", line 42, in fit if x is None: x = arange(y.shape[0])
AttributeError: 'list' object has no attribute 'shape'
As far as I can see, the values included in data are correct, it looks like:
[0.108032, 0.86181600000000003, 1.386169, 3.2790530000000002, ... ]
Has someone a clue what I am doing wrong?
Thanks!