[Numpy-discussion] Line of best fit!

2008-12-08 Thread James
Hi,

I am trying to plot a line of best fit for some data i have, is there a 
simple way of doing it?

Cheers
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Line of best fit!

2008-12-08 Thread Scott Sinclair
 2008/12/8 James [EMAIL PROTECTED]:
 I am trying to plot a line of best fit for some data i have, is there a
 simple way of doing it?

Hi James,

Take a look at:

http://www.scipy.org/Cookbook/FittingData
http://www.scipy.org/Cookbook/LinearRegression

and the section on least square fitting towards the end of this page
in the Scipy docs:

http://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html

Post again if if these references don't get you going.

Cheers,
Scott
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ANN: numpy.i - added managed deallocation to ARGOUTVIEW_ARRAY1 (ARGOUTVIEWM_ARRAY1)

2008-12-08 Thread Egor Zindy
Hello list,

just a quick follow-up on the managed deallocation. This is what I've 
done this week-end:

In numpy.i, I have redefined the import_array() function to also take 
care of the managed memory initialisation (the _MyDeallocType.tp_new = 
PyType_GenericNew; statement). This means that in %init(), the only call 
is to import_array(). Basically, the same as with the normal numpy.i. 
Only difference in a swig file (.i) between unmanaged and managed 
memory allocation is the use of either the ARGOUTVIEW_ARRAY or 
ARGOUTVIEWM_ARRAY fragments. Everything else is hidden.

In numpy.i, this is what's now happening (my previous attempts were a 
bit clumsy):

%#undef import_array
%#define import_array() {if (_import_array()  0) {PyErr_Print(); 
PyErr_SetString(PyExc_ImportError, numpy.core.multiarray failed to 
import); return; }; _MyDeallocType.tp_new = PyType_GenericNew; if 
(PyType_Ready(_MyDeallocType)  0) {PyErr_Print(); 
PyErr_SetString(PyExc_ImportError, Custom memory management failed to 
initialize (numpy.i)); return; }  }

%#undef import_array1
%#define import_array1(ret) {if (_import_array()  0) {PyErr_Print(); 
PyErr_SetString(PyExc_ImportError, numpy.core.multiarray failed to 
import); return ret; }; _MyDeallocType.tp_new = PyType_GenericNew; if 
(PyType_Ready(_MyDeallocType)  0) {PyErr_Print(); 
PyErr_SetString(PyExc_ImportError, Custom memory management failed to 
initialize (numpy.i)); return ret; }  }

%#undef import_array2
%#define import_array2(msg, ret) {if (_import_array()  0) 
{PyErr_Print(); PyErr_SetString(PyExc_ImportError, msg); return ret; }; 
_MyDeallocType.tp_new = PyType_GenericNew; if 
(PyType_Ready(_MyDeallocType)  0) {PyErr_Print(); 
PyErr_SetString(PyExc_ImportError, msg); return ret; } }

My wiki (sorry, haven't moved it to the scipy cookbook yet) has all the 
details (the modified numpy.i, explanations, and some test code):
http://code.google.com/p/ezwidgets/wiki/NumpyManagedMemory

Regards,
Egor

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Python2.4 support

2008-12-08 Thread Adam Mercer
On Sun, Dec 7, 2008 at 23:42, David Cournapeau
[EMAIL PROTECTED] wrote:

 I am strongly against dropping 2.4 support anytime soon. I haven't seen
 a strong rationale for using = 2.5 features in numpy, supporting 2.4 is
 not so hard, and 2.4 is still the default python version on many OS (mac
 os X 10.4 I believe, RHEL for sure, open solaris).

Mac OS X 10.4 uses python-2.3, 10.5 uses python-2.5.

Cheers

Adam
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Python2.4 support

2008-12-08 Thread Matthieu Brucher
 While my feelings aren't as strong as David's, they are pretty much identical.

 As a point of reference, Red Hat Enterprise Linux 6 won't come out
 until at least the first quarter of 2010.  Until then we should make a
 serious effort to support Python 2.4, which ships with RHEL 5.  It
 looks like RHEL 6 will be based on the upcoming Fedora 11 release,
 which will ship with Python 2.6.  That gives us a minimum of one year
 for 2.4 support.  Once RHEL 6 is released, it will take several months
 before a sizable number of users upgrade.

 Moin has a detailed list of Python versions for various OSes and
 hosting services:
  http://moinmo.in/PollAboutRequiringPython24

At least several months, if not years. RedHat supports each version 7
years, for instance (I don't ask for that long).
Currently, I'm still using a RHEL 4, although it is planned to migrate
to RHEL 5 next year. So we should still support 2.4 for at least 18
months, in case some big firms use RHEL and Python+Numpy for their
tools.

-- 
Information System Engineer, Ph.D.
Website: http://matthieu-brucher.developpez.com/
Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn: http://www.linkedin.com/in/matthieubrucher
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Singular Matrix problem with Matplitlib in Numpy (Windows - AMD64)

2008-12-08 Thread George Goussard
Hello.

I have been battling with the following error for the past week. The output 
from the terminal is:

Traceback (most recent call last):
  File 
C:\development\Python\2_5_2\Lib\site-packages\matplotlib\backends\backend_qt4agg.py,
 line 86, in paintEvent
FigureCanvasAgg.draw(self)
  File 
C:\development\Python\2_5_2\Lib\site-packages\matplotlib\backends\backend_agg.py,
 line 261, in draw
self.figure.draw(self.renderer)
  File C:\development\Python\2_5_2\Lib\site-packages\matplotlib\figure.py, 
line 765, in draw
legend.draw(renderer)
  File C:\development\Python\2_5_2\Lib\site-packages\matplotlib\legend.py, 
line 197, in draw
self._update_positions(renderer)
  File C:\development\Python\2_5_2\Lib\site-packages\matplotlib\legend.py, 
line 513, in _update_positions
l,b,w,h = get_tbounds(self.texts[-1])
  File C:\development\Python\2_5_2\Lib\site-packages\matplotlib\legend.py, 
line 499, in get_tbounds
bboxa = bbox.inverse_transformed(self.get_transform())
  File 
C:\development\Python\2_5_2\Lib\site-packages\matplotlib\transforms.py, line 
478, in inverse_transformed
return Bbox(transform.inverted().transform(self.get_points()))
  File 
C:\development\Python\2_5_2\Lib\site-packages\matplotlib\transforms.py, line 
1338, in inverted
self._inverted = Affine2D(inv(mtx))
  File C:\development\Python\2_5_2\Lib\site-packages\numpy\linalg\linalg.py, 
line 350, in inv
return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))
  File C:\development\Python\2_5_2\Lib\site-packages\numpy\linalg\linalg.py, 
line 249, in solve
raise LinAlgError, 'Singular matrix'
numpy.linalg.linalg.LinAlgError: Singular matrix

Initially MPL plots a graph but when you try to interact with the widget(for 
example resize) then the output is displayed and the MPL figure is not updated. 
Everything works with Windows 32-bit. Linux 32-bit and 64-bit are working 
correctly.

Any ideas would be helpful.

Thanks.

George.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] how to create a matrix based on a vector?

2008-12-08 Thread frank wang

Hi,
 
I want to create a matrix based on a vector. It is difficult to describe the 
issue for me in english. Here is an example. 
 
Suppose I have an array([3, 6, 8, 12]), I want to create a range based on each 
element. In this exampe, let us say want to create 4 number with step 2, so I 
will have
 
[3, 6, 8, 12
 5, 8, 10,14
 7, 10,12,16
 9, 12,14,18]
 
It is a 4 by 4 maxtric in this example. My original array is quite large. but 
the range I want to create around the number is not big, it is about 30. 
 
Does anyone know how to do this efficiently?
 
Thanks
 
Frank
_
Send e-mail faster without improving your typing skills.
http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_speed_122008___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to create a matrix based on a vector?

2008-12-08 Thread Robert Kern
On Mon, Dec 8, 2008 at 11:27, frank wang [EMAIL PROTECTED] wrote:
 Hi,

 I want to create a matrix based on a vector. It is difficult to describe the
 issue for me in english. Here is an example.

 Suppose I have an array([3, 6, 8, 12]), I want to create a range based on
 each element. In this exampe, let us say want to create 4 number with step
 2, so I will have

 [3, 6, 8, 12
  5, 8, 10,14
  7, 10,12,16
  9, 12,14,18]

 It is a 4 by 4 maxtric in this example. My original array is quite large.
 but the range I want to create around the number is not big, it is about 30.

 Does anyone know how to do this efficiently?

In [1]: from numpy import *

In [2]: a = array([3, 6, 8, 12])

In [4]: b = arange(0, 4*2, 2)[:,newaxis]

In [5]: a+b
Out[5]:
array([[ 3,  6,  8, 12],
   [ 5,  8, 10, 14],
   [ 7, 10, 12, 16],
   [ 9, 12, 14, 18]])

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth.
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Singular Matrix problem with Matplitlib in Numpy (Windows - AMD64)

2008-12-08 Thread David Cournapeau
On Tue, Dec 9, 2008 at 12:50 AM, George Goussard [EMAIL PROTECTED] wrote:
 Hello.



 I have been battling with the following error for the past week. The output
 from the terminal is:


What does numpy.test() says ? Did you use an external blas/lapack when
you built numpy for AMD64

David
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] checksum on numpy float array

2008-12-08 Thread Francesc Alted
A Sunday 07 December 2008, Brennan Williams escrigué:
 OK so maybe I should

 (1) not add some sort of checksum type functionality to my read/write
 methods

   these read/write methods simply read/write numpy arrays to a
 binary file which contains one or more numpy arrays (and nothing
 else).

 (2) replace my binary files iwith either HDF5 or PyTables

 But

 my app is being used by clients on existing projects - in one case
 there are over 900 of these numpy binary files in just one project,
 albeit each file is pretty small (200KB or so)

 so.. questions.

 How can I tranparently (or at least with minimum user-pain) replace
 my existing read/write methods with PyTables or HDF5?

 My initial thoughts are...

 (a) have an app version number and a data format version number which
 i can check against.

 (b) if data format version  1.0  then read  from old  binary files

 (c) if app version number  1.0 then write to new PyTables or HDF5
 files

 (d) get clients to open existing project and then save existing
 project to semi-transparently convert from old to new formats.

Yeah.  That would work perfectly.  Also, there is a function in PyTables 
named 'isHDF5File(filename)' that allow you to know whether a file is 
in HDF5 format or not.  You might want to use it and avoid to bother 
with data format/app version issues.

Cheers,

Francesc


 Francesc Alted wrote:
  A Friday 05 December 2008, Andrew Collette escrigué:
  Another possibility would be to use HDF5 as a data container.  It
  supports the fletcher32 filter [1] which basically computes a
  chuksum for evey data chunk written to disk and then always check
  that the data read satifies the checksum kept on-disk.  So, if
  the HDF5 layer doesn't complain, you are basically safe.
 
  There are at least two usable HDF5 interfaces for Python and
  NumPy: PyTables[2] and h5py [3].  PyTables does have support for
  that right out-of-the-box.  Not sure about h5py though (a quick
  search in docs doesn't reveal nothing).
 
  [1] http://rfc.sunsite.dk/rfc/rfc1071.html
  [2] http://www.pytables.org
  [3] http://h5py.alfven.org
 
  Hope it helps,
 
  Just to confirm that h5py does in fact have fletcher32; it's one
  of the options you can specify when creating a dataset, although
  it could use better documentation:
 
  http://h5py.alfven.org/docs/guide/hl.html#h5py.highlevel.Group.cre
 ate _dataset
 
  My bad.  I've searched for 'fletcher' instead of 'fletcher32'.  I
  naively thought that the search tool in Sphinx allowed for partial
  name finding.  In fact, it is a pity it does not.
 
  Cheers,

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion



-- 
Francesc Alted
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to create a matrix based on a vector?

2008-12-08 Thread frank wang

I got a lof of help from the experts in this forum. I resitsted to send a thank 
you reply for fearing spaming the forum. This time I really want to let the 
people know that I am really appreciate the great help I got. 
 
Please let me know if a simple thank you message is not appropriate in this 
forum.
 
Numpy makes Pyhton a great tools for processing signal.
 
Thank you very much.
 
Frank  Date: Mon, 8 Dec 2008 11:30:31 -0600 From: [EMAIL PROTECTED] To: 
numpy-discussion@scipy.org Subject: Re: [Numpy-discussion] how to create a 
matrix based on a vector?  On Mon, Dec 8, 2008 at 11:27, frank wang [EMAIL 
PROTECTED] wrote:  Hi,   I want to create a matrix based on a vector. It 
is difficult to describe the  issue for me in english. Here is an example. 
  Suppose I have an array([3, 6, 8, 12]), I want to create a range based on 
 each element. In this exampe, let us say want to create 4 number with step  
2, so I will have   [3, 6, 8, 12  5, 8, 10,14  7, 10,12,16  9, 
12,14,18]   It is a 4 by 4 maxtric in this example. My original array is 
quite large.  but the range I want to create around the number is not big, it 
is about 30.   Does anyone know how to do this efficiently?  In [1]: from 
numpy import *  In [2]: a = array([3, 6, 8, 12])  In [4]: b = arange(0, 
4*2, 2)[:,newaxis]  In [5]: a+b Out[5]: array([[ 3, 6, 8, 12], [ 5, 8, 10, 
14], [ 7, 10, 12, 16], [ 9, 12, 14, 18]])  --  Robert Kern  I have come 
to believe that the whole world is an enigma, a harmless enigma that is made 
terrible by our own mad attempt to interpret it as though it had an underlying 
truth. -- Umberto Eco ___ 
Numpy-discussion mailing list Numpy-discussion@scipy.org 
http://projects.scipy.org/mailman/listinfo/numpy-discussion
_
Send e-mail faster without improving your typing skills.
http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_speed_122008___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to create a matrix based on a vector?

2008-12-08 Thread Robert Kern
On Mon, Dec 8, 2008 at 12:40, frank wang [EMAIL PROTECTED] wrote:
 I got a lof of help from the experts in this forum. I resitsted to send a
 thank you reply for fearing spaming the forum. This time I really want to
 let the people know that I am really appreciate the great help I got.

 Please let me know if a simple thank you message is not appropriate in this
 forum.

Thanks, public or otherwise, are always appreciated. You're quite welcome.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth.
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] What to use to read and write numpy arrays to a file?

2008-12-08 Thread Lou Pecora
In looking for simple ways to read and write data (in a text readable format) 
to and from a file and later restoring the actual data when reading back in, 
I've found that numpy arrays don't seem to play well with repr and eval. 

E.g. to write some data (mixed types) to a file I can do this (fp is an open 
file),

  thedata=[3.0,-4.9+2.0j,'another string']
  repvars= repr(thedata)+\n
  fp.write(repvars)

Then to read it back and restore the data each to its original type,

  strvars= fp.readline()
  sonofdata= eval(strvars)

which gives back the original data list.

BUT when I try this with numpy arrays in the data list I find that repr of an 
array adds extra end-of-lines and that messes up the simple restoration of the 
data using eval.  

Am I missing something simple?  I know I've seen people recommend ways to save 
arrays to files, but I'm wondering what is the most straight-forward?  I really 
like the simple, pythonic approach of the repr - eval pairing.

Thanks for any advice. (yes, I am googling, too)


-- Lou Pecora,   my views are my own.



  
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] What to use to read and write numpy arrays to a file?

2008-12-08 Thread Matthieu Brucher
Hi,

The repr - eval pair does not work with numpy. You can simply do a
tofile() from file().

Matthieu

2008/12/8 Lou Pecora [EMAIL PROTECTED]:
 In looking for simple ways to read and write data (in a text readable format) 
 to and from a file and later restoring the actual data when reading back in, 
 I've found that numpy arrays don't seem to play well with repr and eval.

 E.g. to write some data (mixed types) to a file I can do this (fp is an open 
 file),

  thedata=[3.0,-4.9+2.0j,'another string']
  repvars= repr(thedata)+\n
  fp.write(repvars)

 Then to read it back and restore the data each to its original type,

  strvars= fp.readline()
  sonofdata= eval(strvars)

 which gives back the original data list.

 BUT when I try this with numpy arrays in the data list I find that repr of an 
 array adds extra end-of-lines and that messes up the simple restoration of 
 the data using eval.

 Am I missing something simple?  I know I've seen people recommend ways to 
 save arrays to files, but I'm wondering what is the most straight-forward?  I 
 really like the simple, pythonic approach of the repr - eval pairing.

 Thanks for any advice. (yes, I am googling, too)


 -- Lou Pecora,   my views are my own.




 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion




-- 
Information System Engineer, Ph.D.
Website: http://matthieu-brucher.developpez.com/
Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn: http://www.linkedin.com/in/matthieubrucher
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] What to use to read and write numpy arrays to a file?

2008-12-08 Thread Robert Kern
On Mon, Dec 8, 2008 at 14:54, Lou Pecora [EMAIL PROTECTED] wrote:
 In looking for simple ways to read and write data (in a text readable format) 
 to and from a file and later restoring the actual data when reading back in, 
 I've found that numpy arrays don't seem to play well with repr and eval.

 E.g. to write some data (mixed types) to a file I can do this (fp is an open 
 file),

  thedata=[3.0,-4.9+2.0j,'another string']
  repvars= repr(thedata)+\n
  fp.write(repvars)

 Then to read it back and restore the data each to its original type,

  strvars= fp.readline()
  sonofdata= eval(strvars)

 which gives back the original data list.

 BUT when I try this with numpy arrays in the data list I find that repr of an 
 array adds extra end-of-lines and that messes up the simple restoration of 
 the data using eval.

I don't see any extra end-of-lines. Are you sure you aren't talking
about the ... when you are saving large arrays? You will need to use
set_printoptions() to disable that (threshold=sys.maxint). You should
also adjust use precision=18, suppress=False. That should mostly work,
but it's never a certain thing.

 Am I missing something simple?  I know I've seen people recommend ways to 
 save arrays to files, but I'm wondering what is the most straight-forward?  I 
 really like the simple, pythonic approach of the repr - eval pairing.

 Thanks for any advice. (yes, I am googling, too)

The most bulletproof way would be to use numpy.save() and
numpy.load(), but this is a binary format, not a text one.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth.
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] What to use to read and write numpy arrays to a file?

2008-12-08 Thread Lou Pecora
--- On Mon, 12/8/08, Matthieu Brucher [EMAIL PROTECTED] wrote:

 From: Matthieu Brucher [EMAIL PROTECTED]
 Subject: Re: [Numpy-discussion] What to use to read and write numpy arrays to 
 a file?
 To: Discussion of Numerical Python numpy-discussion@scipy.org
 Date: Monday, December 8, 2008, 3:56 PM
 Hi,
 
 The repr - eval pair does not work with numpy. You can
 simply do a
 tofile() from file().
 
 Matthieu

Yes, I found the tofile/fromfile pair, but they don't preserve the shape.  
Sorry, I should have been clearer on that in my request.  I will be saving 
arrays whose shape I may not know later when I read them in.  I'd like that 
information to be preserved.

Thanks.

-- Lou Pecora,   my views are my own.




  
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] What to use to read and write numpy arrays to a file?

2008-12-08 Thread Lou Pecora
--- On Mon, 12/8/08, Robert Kern [EMAIL PROTECTED] wrote:

 From: Robert Kern [EMAIL PROTECTED]
 Subject: Re: [Numpy-discussion] What to use to read and write numpy arrays to 
 a file?
 
 The most bulletproof way would be to use numpy.save() and
 numpy.load(), but this is a binary format, not a text one.
 
 -- 
 Robert Kern
 

Thanks, Robert.  I may have to go that route, assuming that the save and load 
pair preserve shape, i.e. I don't have to know the shape when I read back in.


-- Lou Pecora,   my views are my own.




  
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] What to use to read and write numpy arrays to a file?

2008-12-08 Thread Robert Kern
On Mon, Dec 8, 2008 at 15:26, Lou Pecora [EMAIL PROTECTED] wrote:
 --- On Mon, 12/8/08, Robert Kern [EMAIL PROTECTED] wrote:

 From: Robert Kern [EMAIL PROTECTED]
 Subject: Re: [Numpy-discussion] What to use to read and write numpy arrays 
 to a file?

 The most bulletproof way would be to use numpy.save() and
 numpy.load(), but this is a binary format, not a text one.

 --
 Robert Kern


 Thanks, Robert.  I may have to go that route, assuming that the save and load 
 pair preserve shape, i.e. I don't have to know the shape when I read back in.

They do.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth.
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Line of best fit!

2008-12-08 Thread Angus McMorland
Hi James,

2008/12/8 James [EMAIL PROTECTED]:

 I have a very simple plot, and the lines join point to point, however i
 would like to add a line of best fit now onto the chart, i am really new
 to python etc, and didnt really understand those links!

 Can anyone help me :)

It sounds like the second link, about linear regression, is a good
place to start, and I've made a very simple example based on that:

---
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 11) #1
data_y = np.random.normal(size=x.shape, loc=x, scale=2.5) #2
plt.plot(x, data_y, 'bo') #3

coefs = np.lib.polyfit(x, data_y, 1) #4
fit_y = np.lib.polyval(coefs, x) #5
plt.plot(x, fit_y, 'b--') #6


Line 1 creates an array with the x values I have. Line 2 creates some
random data I want to fit, which, in this case happens to be
normally distributed around the unity line y=x. The raw data is
plotted (assuming you have matplotlib installed as well - I suggest
you do) by line 3, with blue circles.

Line 4 calculates the coefficients giving the least-squares best fit
to a first degree polynomial (i.e. a straight line y = c0 * x + c1).
So the values of coefs are c0 and c1 in the previous equation.

Line 5 calculates the y values on the fitted polynomial, at given x
values, from the coefficients calculated in line 4, and line 6 simply
plots these fitted y values, using a dotted blue line.

I hope that helps get you started. Keep posting questions on specific
issues as they arise, and we'll see what we can do to help.

Angus.
-- 
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Python2.4 support

2008-12-08 Thread Steven H. Rogers
Matthieu Brucher wrote:
 At least several months, if not years. RedHat supports each version 7
 years, for instance (I don't ask for that long).
 Currently, I'm still using a RHEL 4, although it is planned to migrate
 to RHEL 5 next year. So we should still support 2.4 for at least 18
 months, in case some big firms use RHEL and Python+Numpy for their
 tools.
   
+1

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] how do I delete unused matrix to save the memory?

2008-12-08 Thread frank wang

Hi,
 
I have a program with some variables consume a lot of memory. The first time I 
run it, it is fine. The second time I run it, I will get MemoryError. If I 
close the ipython and reopen it again, then I can run the program once. I am 
looking for a command to delete the intermediate variable once it is not used 
to save memory like in matlab clear command.
 
Thanks
 
Frank
_
Send e-mail faster without improving your typing skills.
http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_speed_122008___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how do I delete unused matrix to save the memory?

2008-12-08 Thread Travis Vaught

Try:

del(myvariable)

Travis

On Dec 8, 2008, at 7:15 PM, frank wang [EMAIL PROTECTED] wrote:


Hi,

I have a program with some variables consume a lot of memory. The  
first time I run it, it is fine. The second time I run it, I will  
get MemoryError. If I close the ipython and reopen it again, then I  
can run the program once. I am looking for a command to delete the  
intermediate variable once it is not used to save memory like in  
matlab clear command.


Thanks

Frank

Send e-mail faster without improving your typing skills. Get your  
Hotmail® account.

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] when will osx linker option -bundle be reflected in distutils

2008-12-08 Thread Garry Willgoose
I was just wondering what plans there were to reflect the different  
linker options (i.e. -bundle instead of -shared) that are required on  
OSX in the fcompiler files within distutils. While its a minor thing  
it always catches the users of my software when they either install  
fresh or update numpy ... and sometimes on a bad day it even catches  
me ;-)

Prof Garry Willgoose,
Australian Professorial Fellow in Environmental Engineering,
Director, Centre for Climate Impact Management (C2IM),
School of Engineering, The University of Newcastle,
Callaghan, 2308
Australia.

Centre webpage: www.c2im.org.au

Phone: (International) +61 2 4921 6050 (Tues-Fri AM); +61 2 6545 9574  
(Fri PM-Mon)
FAX: (International) +61 2 4921 6991 (Uni); +61 2 6545 9574 (personal  
and Telluric)
Env. Engg. Secretary: (International) +61 2 4921 6042

email:  [EMAIL PROTECTED]; [EMAIL PROTECTED]
email-for-life: [EMAIL PROTECTED]
personal webpage: www.telluricresearch.com/garry

Do not go where the path may lead, go instead where there is no path  
and leave a trail
   Ralph Waldo Emerson






___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] when will osx linker option -bundle be reflected in distutils

2008-12-08 Thread Robert Kern
On Mon, Dec 8, 2008 at 18:02, Garry Willgoose
[EMAIL PROTECTED] wrote:
 I was just wondering what plans there were to reflect the different
 linker options (i.e. -bundle instead of -shared) that are required on
 OSX in the fcompiler files within distutils. While its a minor thing
 it always catches the users of my software when they either install
 fresh or update numpy ... and sometimes on a bad day it even catches
 me ;-)

I'm sorry; I don't follow. What problems are you having?

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth.
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Line of best fit!

2008-12-08 Thread Scott Sinclair
 2008/12/9 Angus McMorland [EMAIL PROTECTED]:
 Hi James,

 2008/12/8 James [EMAIL PROTECTED]:

 I have a very simple plot, and the lines join point to point, however i
 would like to add a line of best fit now onto the chart, i am really new
 to python etc, and didnt really understand those links!

 Can anyone help me :)

 It sounds like the second link, about linear regression, is a good
 place to start, and I've made a very simple example based on that:

 ---
 import numpy as np
 import matplotlib.pyplot as plt

 x = np.linspace(0, 10, 11) #1
 data_y = np.random.normal(size=x.shape, loc=x, scale=2.5) #2
 plt.plot(x, data_y, 'bo') #3

 coefs = np.lib.polyfit(x, data_y, 1) #4
 fit_y = np.lib.polyval(coefs, x) #5
 plt.plot(x, fit_y, 'b--') #6
 

James, you'll want to add an extra line to the above code snippet so
that Matplotlib displays the plot:

plt.show()

Cheers,
Scott
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] genloadtxt : last call

2008-12-08 Thread Ryan May
Pierre GM wrote:
 All,
 Here's the latest version of genloadtxt, with some recent corrections. 
 With just a couple of tweaking, we end up with some decent speed: it's 
 still slower than np.loadtxt, but only 15% so according to the test at 
 the end of the package.
 
 And so, now what ? Should I put the module in numpy.lib.io ? Elsewhere ?
 
 Thx for any comment and suggestions.

Current version works out of the box for me.

Thanks for running point on this.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion