Issues with numpy or more likely myself. 04-12-2013, 06:01 PM
#1
*snip*
“The first principle is that you must not fool yourself and you are the easiest person to fool.” - Feynman
| Issues with numpy or more likely myself. filter_list | |
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)
(04-12-2013, 07:07 PM)Deque Wrote: Please explain or make a small example: What is the content of the txt file and what output do you expect?
mean = sum(x)/100.0(04-12-2013, 07:24 PM)-ELM Wrote:(04-12-2013, 07:07 PM)Deque Wrote: Please explain or make a small example: What is the content of the txt file and what output do you expect?
Apologies for my lack of clarity. The file being imported is simply two columns of one hundred lines of data. I'm trying to manipulate the data such that I can work out statistical properties such as the mean by:
However the [x] array I am trying to read from is not being registered and consequently python is giving me a default array of numbers from one to hundred.Code:mean = sum(x)/100.0
More specifically the plotted data follows a trend of which I am familiar with and know the general equation of. My intent is to try and fit this general curve to the data set and compare with other curve fittings using inbuilt routines from other Python modules.
>>> c = StringIO("1,0,2\n3,0,4")
>>> x, y = np.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True)
>>> x
array([ 1., 3.])
>>> y
array([ 2., 4.])![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)
(04-12-2013, 07:49 PM)Deque Wrote:(04-12-2013, 07:24 PM)-ELM Wrote:(04-12-2013, 07:07 PM)Deque Wrote: Please explain or make a small example: What is the content of the txt file and what output do you expect?
Apologies for my lack of clarity. The file being imported is simply two columns of one hundred lines of data. I'm trying to manipulate the data such that I can work out statistical properties such as the mean by:
However the [x] array I am trying to read from is not being registered and consequently python is giving me a default array of numbers from one to hundred.Code:mean = sum(x)/100.0
More specifically the plotted data follows a trend of which I am familiar with and know the general equation of. My intent is to try and fit this general curve to the data set and compare with other curve fittings using inbuilt routines from other Python modules.
I well understood what you want to do. But I need an example of how your file looks like.
You say you get an array with numbers from 1 to 100 in it. There is a reason for this and to find the reason properly I need a little and concrete example of the contents of your txt file (I guess a few lines would be sufficient).
I see that there is similar example here: http://docs.scipy.org/doc/numpy/referenc...adtxt.html
Code:>>> c = StringIO("1,0,2\n3,0,4") >>> x, y = np.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True) >>> x array([ 1., 3.]) >>> y array([ 2., 4.])
But here they specified a delimiter and which columns to put in x and y. You didn't specify that, so I am asking myself what kind of data you expect to be in x, if there are not several columns you can unpack.
The only thing that gives me more clarity is your .txt file.
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)