From vroudnev at ksu.edu Tue Feb 1 12:47:04 2005 From: vroudnev at ksu.edu (Vladimir Roudnev) Date: Tue, 01 Feb 2005 11:47:04 -0600 Subject: [SciPy-user] Re: vectorize(function)/arraymap did not return arrays? In-Reply-To: <41FE803B.50108@usc.edu> References: <41F01369.4000807@usc.edu> <41F070DB.4010905@usc.edu> <41F16EB8.6080308@usc.edu> <41F71EB4.3090504@usc.edu> <41FE803B.50108@usc.edu> Message-ID: <41FFC098.9040307@ksu.edu> > So I have to loop through all the rows and columns on this grid, at > this point I found the nested looping is kind of slow to my > expectation, and the inner function call to the convolution function, > since it's using scipy's fftpack or Numeric, I do not think the inner > function call could be speeded a lot more by written C code in weave. If you are so sure that it is the python nested loops construcion that cause the performance degradation, why would not you just unroll the inner loop manually and compare the performance? I'm too far from being familiar with how the execution environment is organized, but I am really surprised that such simple construction as nested loops can cause a performance degradation... It sounds counterintuitive for me... From eileenye00 at yahoo.com Tue Feb 1 12:47:43 2005 From: eileenye00 at yahoo.com (eileen ye) Date: Tue, 1 Feb 2005 09:47:43 -0800 (PST) Subject: [SciPy-user] installation failed on a Intel 64 bit chip Message-ID: <20050201174743.12128.qmail@web51005.mail.yahoo.com> Sorry to bother you. I am trying install scipy on a Redhat 64 bit linux machine. I have python 2.2, and I can install Number-23.0, however, Numeric-23.5, Numeric-23.6, Numeric-23.7, report with the same error message. ************************************************************************** gcc -shared build/temp.linux-x86_64-2.2/lapack_litemodule.o -L/usr/lib/atlas -llapack -lcblas -lf77blas -latlas -lg2c -o build/lib.linux-x86_64-2.2/lapack_lite.so /usr/bin/ld: /usr/lib/gcc-lib/x86_64-redhat-linux/3.2.3/../../../libf77blas.a(sgbmv.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc-lib/x86_64-redhat-linux/3.2.3/../../../libf77blas.a: could not read symbols: Bad value collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 ************************************************************************** Since I installed Numeric-23.0, so I tried to build Scipy from source code. Scipy reported error as ************************************************************************* g77:f77: build/src/build/src/scipy/linalg/fblas-f2pywrappers.f /usr/bin/g77 -shared build/temp.linux-x86_64-2.2/fblasmodule.o build/temp.linux-x86_64-2.2/fortranobject.o build/temp.linux-x86_64-2.2/Lib/linalg/src/fblaswrap.o build/temp.linux-x86_64-2.2/build/src/build/src/scipy/linalg/fblas-f2pywrappers.o -L/usr/lib -Lbuild/temp.linux-x86_64-2.2 -llapack -lf77blas -lcblas -latlas -lg2c -o build/lib.linux-x86_64-2.2/scipy/linalg/fblas.so /usr/bin/ld: /usr/lib/libf77blas.a(sgemv.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC /usr/lib/libf77blas.a: could not read symbols: Bad value collect2: ld returned 1 exit status /usr/bin/ld: /usr/lib/libf77blas.a(sgemv.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC /usr/lib/libf77blas.a: could not read symbols: Bad value collect2: ld returned 1 exit status error: Command "/usr/bin/g77 -shared build/temp.linux-x86_64-2.2/fblasmodule.o build/temp.linux-x86_64-2.2/fortranobject.o build/temp.linux-x86_64-2.2/Lib/linalg/src/fblaswrap.o build/temp.linux-x86_64-2.2/build/src/build/src/scipy/linalg/fblas-f2pywrappers.o -L/usr/lib -Lbuild/temp.linux-x86_64-2.2 -llapack -lf77blas -lcblas -latlas -lg2c -o build/lib.linux-x86_64-2.2/scipy/linalg/fblas.so" failed with exit status 1 ********************************************************************* I am root, so there is no privilege problem. Any suggestion? Thank you very much Eileen --------------------------------- Do you Yahoo!? Yahoo! Search presents - Jib Jab's 'Second Term' -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephen.walton at csun.edu Tue Feb 1 19:25:30 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Tue, 01 Feb 2005 16:25:30 -0800 Subject: [SciPy-user] installation failed on a Intel 64 bit chip In-Reply-To: <20050201174743.12128.qmail@web51005.mail.yahoo.com> References: <20050201174743.12128.qmail@web51005.mail.yahoo.com> Message-ID: <42001DFA.6050609@csun.edu> eileen ye wrote: > Sorry to bother you. I am trying install scipy on a Redhat 64 > bit linux machine. > ... > gcc -shared build/temp.linux-x86_64-2.2/lapack_litemodule.o > -L/usr/lib/atlas -llapack -lcblas -lf77blas -latlas -lg2c -o > build/lib.linux-x86_64-2.2/lapack_lite.so > /usr/bin/ld: > /usr/lib/gcc-lib/x86_64-redhat-linux/3.2.3/../../../libf77blas.a(sgbmv.o): ^^^^^^^^^ This is your problem. The libf77blas.a which is being accessed is the one in the RedHat lapack RPM instead of the one for ATLAS. You'll have to uninstall it: rpm -e lapack octave since, if I recall, octave depends on lapack. From joris at ster.kuleuven.ac.be Wed Feb 2 07:51:08 2005 From: joris at ster.kuleuven.ac.be (Joris De Ridder) Date: Wed, 2 Feb 2005 13:51:08 +0100 Subject: [SciPy-user] read_array() Message-ID: <200502021351.08017.joris@ster.kuleuven.ac.be> Hi, I have two questions about the read_array() function in scipy.io. As a simple example, suppose you have a file containing only 2 lines: 1. a 3 1. a 3 read_array("myfile.txt") gives the expected array([[ 1., 0., 3.], [ 1., 0., 3.]]) where 0 is inserted for a failed number conversion. However, read_array("myfile.txt", missing = 2.) still inserts 0 and not 2. Do I misunderstand this option? Secondly, the docstring mentions that you can also get "a tuple of output arrays of different types". I have tried several possibilities to get 2 arrays, one with the first column in a float array and a second one with the third column in an integer array, but I don't seem to manage. I would be very grateful if someone could email me a simple example on how to do this. Cheers, Joris From eileenye00 at yahoo.com Wed Feb 2 11:47:57 2005 From: eileenye00 at yahoo.com (eileen ye) Date: Wed, 2 Feb 2005 08:47:57 -0800 (PST) Subject: [SciPy-user] installation failed on a Intel 64 bit chip In-Reply-To: <42001DFA.6050609@csun.edu> Message-ID: <20050202164757.61254.qmail@web51008.mail.yahoo.com> Thank you very much for the reply. I uninstalled lapack. Numeric-23.7 installation still failed by the same command with the same error. I am using my own atlas. gcc -shared build/temp.linux-x86_64-2.2/lapack_litemodule.o -L/usr/local/atlas/ATLAS/lib/Linux_X86_64_4 -llapack -lcblas -lf77blas -latlas -lg2c -o build/lib.linux-x86_64-2.2/lapack_lite.so /usr/bin/ld: /usr/local/atlas/ATLAS/lib/Linux_X86_64_4/liblapack.a(dgeev.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC /usr/local/atlas/ATLAS/lib/Linux_X86_64_4/liblapack.a: could not read symbols: Bad value collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 Stephen Walton wrote: eileen ye wrote: > Sorry to bother you. I am trying install scipy on a Redhat 64 > bit linux machine. > ... > gcc -shared build/temp.linux-x86_64-2.2/lapack_litemodule.o > -L/usr/lib/atlas -llapack -lcblas -lf77blas -latlas -lg2c -o > build/lib.linux-x86_64-2.2/lapack_lite.so > /usr/bin/ld: > /usr/lib/gcc-lib/x86_64-redhat-linux/3.2.3/../../../libf77blas.a(sgbmv.o): ^^^^^^^^^ This is your problem. The libf77blas.a which is being accessed is the one in the RedHat lapack RPM instead of the one for ATLAS. You'll have to uninstall it: rpm -e lapack octave since, if I recall, octave depends on lapack. _______________________________________________ SciPy-user mailing list SciPy-user at scipy.net http://www.scipy.net/mailman/listinfo/scipy-user __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From prabhu_r at users.sf.net Wed Feb 2 14:20:45 2005 From: prabhu_r at users.sf.net (Prabhu Ramachandran) Date: Thu, 3 Feb 2005 00:50:45 +0530 Subject: [SciPy-user] ANN: MayaVi-1.4 released Message-ID: <16897.10253.283247.867756@monster.linux.in> Hi, This is to announce the availability of the (long overdue) MayaVi Data Visualizer version 1.4. MayaVi is a free, easy to use, scientific data visualizer. It is written in Python, uses the Visualization Toolkit (VTK) for the graphics and provides a GUI written using Tkinter. MayaVi is distributed under a BSD license. It is also cross platform and should run on any platform where both Python and VTK are available. For more information, sources, binaries, screenshots, installation instructions, documentation etc. visit the MayaVi home page at: http://mayavi.sourceforge.net Also bundled with MayaVi is a VTK pipeline browser written in Python and a utility module that makes using VTK easier from the Python interpreter. New in this release: * Support for data files belonging to a time series. It is also possible to sweep through the time series. Thanks to Gerard Gorman for an initial patch! * Support for user defined modules and filters. A search path may be specified in the preferences. User defined modules and filters are searched for in these directories and automatically picked up by MayaVi. Thanks to Fernando Perez for an initial patch! * Fixed critical bugs in the Volume module. Anyone using the Volume module from the 1.3 release should upgrade! * Miscellaneous enhancements: allow the user to disable rendering temporarily, user can specify geometry of the MayaVi window. * Several other bug fixes and minor enhancements. Acknowledgements: Many thanks to SourceForge for their continued support in hosting MayaVi. Thanks also to various users who provided patches, bug reports, support and suggestions. Have fun! prabhu From pearu at scipy.org Thu Feb 3 13:41:40 2005 From: pearu at scipy.org (Pearu Peterson) Date: Thu, 3 Feb 2005 12:41:40 -0600 (CST) Subject: [SciPy-user] installation failed on a Intel 64 bit chip In-Reply-To: <20050202164757.61254.qmail@web51008.mail.yahoo.com> References: <20050202164757.61254.qmail@web51008.mail.yahoo.com> Message-ID: On Wed, 2 Feb 2005, eileen ye wrote: > Thank you very much for the reply. > > I uninstalled lapack. Numeric-23.7 installation still failed by the same command with the same error. I am using my own atlas. > > gcc -shared build/temp.linux-x86_64-2.2/lapack_litemodule.o > -L/usr/local/atlas/ATLAS/lib/Linux_X86_64_4 -llapack -lcblas -lf77blas -latlas -lg2c -o build/lib.linux-x86_64-2.2/lapack_lite.so > /usr/bin/ld: /usr/local/atlas/ATLAS/lib/Linux_X86_64_4/liblapack.a(dgeev.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC > /usr/local/atlas/ATLAS/lib/Linux_X86_64_4/liblapack.a: could not read symbols: Bad value > collect2: ld returned 1 exit status > error: command 'gcc' failed with exit status 1 To build LAPACK library for Opteron, I had to use OPTS = -funroll-all-loops -O3 -m64 -fno-second-underscore -fPIC NOOPT = -m64 -fno-second-underscore -fPIC in LAPACK/make.inc. '-m64 -fPIC' should be used also in ATLAS/Make.$ARCH file for variables like F77FLAGS, CCFLAG0, MMFLAGS. HTH, Pearu From nwagner at mecha.uni-stuttgart.de Fri Feb 4 07:50:41 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Fri, 04 Feb 2005 13:50:41 +0100 Subject: [SciPy-user] compiler optimization bug -fno-f2c Message-ID: <42036FA1.2030902@mecha.uni-stuttgart.de> Hi all, Is it a well-known compiler optimization bug (-fno-f2c) ? I am curious about it. Nils From stephen.walton at csun.edu Fri Feb 4 13:27:24 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Fri, 04 Feb 2005 10:27:24 -0800 Subject: [SciPy-user] compiler optimization bug -fno-f2c In-Reply-To: <42036FA1.2030902@mecha.uni-stuttgart.de> References: <42036FA1.2030902@mecha.uni-stuttgart.de> Message-ID: <4203BE8C.2000704@csun.edu> Nils Wagner wrote: Hello, Nils, > Is it a well-known compiler optimization bug (-fno-f2c) ? It is not a bug per se. From man g77: The f2c calling conventions require functions that return type "REAL(KIND=1)" to actually return the C type "double", and func- tions that return type "COMPLEX" to return the values via an extra argument in the calling sequence that points to where to store the return value. Under the GNU calling conventions, such functions simply return their results as they would in GNU C---"REAL(KIND=1)" functions return the C type "float", and "COM- PLEX" functions return the GNU C type "complex" (or its "struct" equivalent). Ideally, both in terms of time and storage, all code would be compiled with -no-f2c. But as the man page says later on, all Fortran source code in a program must be compiled with this switch if any of it is. From ckkart at hoc.net Mon Feb 7 10:43:32 2005 From: ckkart at hoc.net (Christian Kristukat) Date: Mon, 07 Feb 2005 16:43:32 +0100 Subject: [SciPy-user] fmin_tnc error? Message-ID: <42078CA4.2080306@hoc.net> Hi, I probably found an error in optimize.fmin_tnc. I was not able to supply an upper bound. If, e.g. I set the bounds to [-1,.1] I get: tnc: Version 1.2, (c) 2002-2003, Jean-Sebastien Roy (js at jeannot.org) tnc: RCS ID: @(#) $Jeannot: tnc.c,v 1.201 2004/04/02 22:36:25 js Exp $ tnc: All lower bounds are equal to the upper bounds [-0.10000000000000001] It only works when setting the upper bound to None. scipy.__version__ is 0.3.2_288.4353 Regards, Christian From kuhlman at hwr.arizona.edu Mon Feb 7 13:30:09 2005 From: kuhlman at hwr.arizona.edu (Kris Kuhlman) Date: Mon, 07 Feb 2005 11:30:09 -0700 Subject: [SciPy-user] help upgrading / installing scipy.special Message-ID: <4207B3B1.4040607@hwr.arizona.edu> Hello, I don't have much experience with python; I am trying to get a program running which uses a compiled fortran extension for calculating Bessel functions as well as the SciPy libraries. I have SciPy installed and I did the tests listed on the website, they said it was OK, but this program needs scipy.special (or at least this is where it hangs up when I run it, there may be more SciPy dependencies I haven't run into), which I don't appear to have installed. How do I add this? Do I uninstall the whole thing, and download the Linux binaries? How do I install the Linux binaries available on the scipy.org website? do I just copy them into the directory tree? The files in the binary package don't correspond 1:1 with the files I have in the same directories in my SciPy setup. I was hoping to get this working from binaries without having to install atlas and blas, or do I need to rebuild it from source? I am using Fedora Core 2, I have python 2.3, numpy 23.3 and F2PY installed. Thanks. Kris From kuhlman at hwr.arizona.edu Mon Feb 7 14:58:26 2005 From: kuhlman at hwr.arizona.edu (Kris Kuhlman) Date: Mon, 07 Feb 2005 12:58:26 -0700 Subject: [SciPy-user] help upgrading / installing scipy.special In-Reply-To: <4207B3B1.4040607@hwr.arizona.edu> References: <4207B3B1.4040607@hwr.arizona.edu> Message-ID: <4207C862.30904@hwr.arizona.edu> Never mind. I figured it out. thanks. Kris Kuhlman wrote: >Hello, > >I don't have much experience with python; I am trying to get a program >running which uses a compiled fortran extension for calculating Bessel >functions as well as the SciPy libraries. I have SciPy installed and I >did the tests listed on the website, they said it was OK, but this >program needs scipy.special (or at least this is where it hangs up when >I run it, there may be more SciPy dependencies I haven't run into), >which I don't appear to have installed. > >How do I add this? Do I uninstall the whole thing, and download the >Linux binaries? How do I install the Linux binaries available on the >scipy.org website? do I just copy them into the directory tree? The >files in the binary package don't correspond 1:1 with the files I have >in the same directories in my SciPy setup. > >I was hoping to get this working from binaries without having to install >atlas and blas, or do I need to rebuild it from source? I am using >Fedora Core 2, I have python 2.3, numpy 23.3 and F2PY installed. > >Thanks. > >Kris > >_______________________________________________ >SciPy-user mailing list >SciPy-user at scipy.net >http://www.scipy.net/mailman/listinfo/scipy-user > > > From fonnesbeck at gmail.com Mon Feb 7 21:17:13 2005 From: fonnesbeck at gmail.com (Chris Fonnesbeck) Date: Mon, 7 Feb 2005 21:17:13 -0500 Subject: [SciPy-user] ANN: PyMC 0.7.1 Message-ID: <723eb69305020718174f2aa530@mail.gmail.com> PyMC is a Python module that provides a general Markov chain Monte Carlo (MCMC) algorithm, making Bayesian simulation models relatively easy to implement. PyMC is not an application per se, but rather a set of classes that relieves users of the need for re-implementing MCMC algorithms and associated utilities, such as plotting and statistical summary. This allows the user to concentrate on important aspects of the problem at hand, rather than the mundane details of statistical simulation. Version 0.7.1 includes several improvements: - Plotting via Matplotlib - Calculation of model deviance and DIC - Output files for CODA analysis - Several new likelihood distributions - New User's guide For more information, please visit: http://pymc.sourceforge.net Thanks, Chris Fonnesbeck From beyer at imb-jena.de Tue Feb 8 04:06:11 2005 From: beyer at imb-jena.de (Andreas Beyer) Date: Tue, 08 Feb 2005 10:06:11 +0100 Subject: [SciPy-user] Scipy for Python 2.4 Message-ID: <42088103.7060806@imb-jena.de> Hi, Has anybody a binary for Python 2.4 on Windows ready to use? It would be great if such binary could also be made available on the download-site. BTW I am using Numeric 23.7, the binaries on the web-site are still for Numeric 23.5. Andreas From deferran at karavel.com Tue Feb 8 10:22:52 2005 From: deferran at karavel.com (Manuel de Ferran) Date: Tue, 08 Feb 2005 16:22:52 +0100 Subject: [SciPy-user] Arrays and sorting methods Message-ID: <4208D94C.10702@karavel.com> Greetings scipy-list, my question might a bit off-topic. I m planning to use scipy for array manipulation. I know that scipy is not mainly designed for that. I was surprised that I could not find any sorting array based on the columns, that might be usefull with itemfreq(), for instance. Do you implement your own sorting algorithms ? Use a different package ? Regards, Manuel From aisaac at american.edu Tue Feb 8 11:06:10 2005 From: aisaac at american.edu (Alan G Isaac) Date: Tue, 8 Feb 2005 11:06:10 -0500 (Eastern Standard Time) Subject: [SciPy-user] Arrays and sorting methods In-Reply-To: <4208D94C.10702@karavel.com> References: <4208D94C.10702@karavel.com> Message-ID: On Tue, 08 Feb 2005, Manuel de Ferran apparently wrote: > I was surprised that I could not find any sorting array based on the > columns, that might be usefull with itemfreq(), for instance. This is from http://www.american.edu/econ/pytrix/pyGAUSS.py hth, Alan Isaac #sortc: sort array on specified column NUMBER # NOT (!!) on column *index* (=colNUM-1)''' # Format: y = sortc(x,colNUM) # Input: x RxC array # colNUM integer # Output: y RxC array # Remarks: sorts on column *NUMBER* # (starting at 1, following GAUSS convention) # NOT (!!) on column *index* (=colNUM-1) # Date: 5 Aug 2004 def sortc(x,colNUM): if not colNUM in range(1,1+shape(x)[1]): raise ValueError, 'Index out of range.' return take(x,argsort(asarray(x)[:,colNUM-1],0)) From cdavis at staffmail.ed.ac.uk Tue Feb 8 13:04:22 2005 From: cdavis at staffmail.ed.ac.uk (Cory Davis) Date: 08 Feb 2005 18:04:22 +0000 Subject: [SciPy-user] cow socket.error Message-ID: <1107885861.15235.10.camel@fog> Hi All, Can any one tell me what is going on here? It seems that some socket error is stopping my cluster from starting up. In [6]: slave_list = [ ('slave.number.one',2345), ('slave.number.two',2345)] In [7]: cluster = scipy.cow.machine_cluster(slave_list) In [8]: cluster.start(timeout=200) cory at slave.number.one's password: cory at slave.number.two's password: Starting Servers |----|----|----15---|----|----30---|----|----45---|----|----60 0............................................................ 1........................................................... 2........................................................... --------------------------------------------------------------------------- TimeoutError Traceback (most recent call last) /home/cory/ /eosmls/local/linux/lib/python/scipy/cow/cow.py in start(self, force_restart, timeout) 160 print minute, 161 if elapsed > timeout: --> 162 raise TimeoutError 163 print 'servers running!' 164 TimeoutError: None 3.................... And when I look at /tmp/crud2345, which is where the output of the ssh command is piped to I get ... [cory at slave.number.one tmp]$ cat crud2345 starting server on slave.numer.one:2345 23631 Traceback (most recent call last): File "/eosmls/local/linux/lib/python/scipy/cow/sync_cluster.py", line 898, in ? server(host,port) File "/eosmls/local/linux/lib/python/scipy/cow/sync_cluster.py", line 853, in server the_server=MyThreadingTCPServer( (host, port), standard_sync_handler) File "/eosmls/local/linux/lib/python2.3/SocketServer.py", line 330, in __init__ self.server_bind() File "/eosmls/local/linux/lib/python2.3/SocketServer.py", line 341, in server_bind self.socket.bind(self.server_address) File "", line 1, in bind socket.error: (99, 'Cannot assign requested address') Any ideas? Cheers, Cory From Louis.Wicker at noaa.gov Wed Feb 9 00:53:14 2005 From: Louis.Wicker at noaa.gov (Louis Wicker) Date: Tue, 8 Feb 2005 23:53:14 -0600 Subject: [SciPy-user] large arrays ( > 2 gb) in numarray? Message-ID: Hello, I am new to the list. I have been building a python-fortran ensemble Kalman filter system for assimilating radar data into convective cloud models. I am running into a big problem that I thought I would ask about. I am designing this system for the SGI Altix machines, which is a Linux64 box with > 15 Gb of memory. I ran into the problem that Numeric or Numarray will not allow me to allocate an array larger than 2 gb. Is this a fundamental limitation of numarray/Numeric, or do I need to compile numarray/Numeric in some what to get it to use 64 bit pointers. For example, here is the failure mode... >>> a = numarray.zeros((200,200,50,12,40), typecode='f') Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.2/site-packages/numarray/numarraycore.py", line 1200, in zeros retarr = NumArray(shape=shape, type=type) libnumarray.error: NA_updateDataPtr: error getting read buffer data ptr any ideas? this is running python2.3 and numarray 1.1 Thanks. Lou Wicker ------------------------------------------------------------------------ ---- | Dr. Louis J. Wicker | Research Scientist, National Severe Storms Lab | 1313 Halley Cir, Norman, OK 73069 | E-mail: Louis.Wicker at nssl.noaa.gov | HTTP: www.nssl.noaa.gov/~lwicker | Phone: (405) 366-0416 | Fax: (405) 366-0472 ------------------------------------------------------------------------ ---- From ckkart at hoc.net Wed Feb 9 06:28:46 2005 From: ckkart at hoc.net (Christian Kristukat) Date: Wed, 09 Feb 2005 12:28:46 +0100 Subject: [SciPy-user] fmin_tnc error? In-Reply-To: <42078CA4.2080306@hoc.net> References: <42078CA4.2080306@hoc.net> Message-ID: <4209F3EE.80906@hoc.net> Christian Kristukat wrote: > Hi, > I probably found an error in optimize.fmin_tnc. I was not able to supply > an upper bound. If, e.g. I set the bounds to [-1,.1] I get: > > tnc: Version 1.2, (c) 2002-2003, Jean-Sebastien Roy (js at jeannot.org) > tnc: RCS ID: @(#) $Jeannot: tnc.c,v 1.201 2004/04/02 22:36:25 js Exp $ > tnc: All lower bounds are equal to the upper bounds > [-0.10000000000000001] > > It only works when setting the upper bound to None. > I found the bug in optimize/tnc.py. Here's a patch. It fixes two more small errors: - the tests called the wrong minimize function - the parameter maxnfeval appeared as maxfun at some places --- scipy/Lib/optimize/tnc.py 2005-02-09 12:22:25.000000000 +0100 +++ /usr/lib/python/site-packages/scipy/optimize/tnc.py 2005-02-09 12:20:55.000000000 +0100 @@ -120,8 +120,8 @@ if maxCGit == 0, the direction chosen is -gradient if maxCGit < 0, maxCGit is set to max(1,min(50,n/2)) defaults to -1 - maxnfeval : max. number of function evaluation - if None, maxnfeval is set to max(1000, 100*len(x0)) + maxfun : max. number of function evaluation + if None, maxfun is set to max(1000, 100*len(x0)) defaults to None eta : severity of the line search. if < 0 or > 1, set to 0.25 defaults to -1 @@ -185,7 +185,7 @@ if u is None: up[i] = HUGE_VAL else: - up[i] = l + up[i] = u if scale == None: scale = [] @@ -213,7 +213,7 @@ return f, g # Optimizer call - rc, nf, x = minimize(function, [-7, 3], bounds=([-10, 10], [1, 10])) + rc, nf, x = fmin_tnc(function, [-7, 3], bounds=([-10, 10], [1, 10])) print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] print "x =", x @@ -297,7 +297,7 @@ def test(fg, x, bounds, xopt): print "** Test", fg.__name__ - rc, nf, x = minimize(fg, x, bounds=bounds, messages = MSG_NONE, maxnfeval = 200) + rc, nf, x = fmin_tnc(fg, x, bounds=bounds, messages = MSG_NONE, maxfun = 200) print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] print "x =", x print "exact value =", xopt From perry at stsci.edu Wed Feb 9 14:18:49 2005 From: perry at stsci.edu (Perry Greenfield) Date: Wed, 9 Feb 2005 14:18:49 -0500 Subject: [SciPy-user] large arrays ( > 2 gb) in numarray? In-Reply-To: Message-ID: Louis Wicker wrote: > > I am running into a big problem that I thought I would ask about. > > I am designing this system for the SGI Altix machines, which is a > Linux64 box with > 15 Gb of memory. > > I ran into the problem that Numeric or Numarray will not allow me to > allocate an array larger than 2 gb. Is this a fundamental limitation > of numarray/Numeric, or Yes and no. Currently the limitation is driven by the fact that Python uses 32 bit integers for indexing sequence objects, and it is desired that Numeric and numarray support that protocol for many good reasons. The good news is that work is well underway to change Python to support 64-bit sequence indices. The bad new is that it will take at least a few months for these changes to show up in a version of Python that we can test updated versions of numarray (or Numeric, or Numeric3) against. This capability should be present within the next 6 months to a year I'm guessing. Perry Greenfield From stephen.walton at csun.edu Wed Feb 9 19:52:14 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Wed, 09 Feb 2005 16:52:14 -0800 Subject: [SciPy-user] lognormal distribution Message-ID: <420AB03E.5090605@csun.edu> An application question for a change: I need to produce pseudorandom numbers drawn from a lognormal distribution (see http://www.itl.nist.gov/div898/handbook/eda/section3/eda3669.htm). Does anyone have existing code for this in Numeric or numarray? From Fernando.Perez at colorado.edu Wed Feb 9 19:57:08 2005 From: Fernando.Perez at colorado.edu (Fernando Perez) Date: Wed, 09 Feb 2005 17:57:08 -0700 Subject: [SciPy-user] lognormal distribution In-Reply-To: <420AB03E.5090605@csun.edu> References: <420AB03E.5090605@csun.edu> Message-ID: <420AB164.7070007@colorado.edu> Stephen Walton wrote: > An application question for a change: I need to produce pseudorandom > numbers drawn from a lognormal distribution (see > http://www.itl.nist.gov/div898/handbook/eda/section3/eda3669.htm). Does > anyone have existing code for this in Numeric or numarray? In [24]: scipy.stats.lognorm? Type: instance Base Class: scipy.stats.distributions.lognorm_gen String Form: Namespace: Interactive Docstring: A lognormal continuous random variable. Continuous random variables are defined from a standard form chosen for simplicity of representation. The standard form may require some shape parameters to complete its specification. The distributions also take optional location and scale parameters using loc= and scale= keywords (defaults: loc=0, scale=1) I'm not a stats person, so perhaps this one is not enough for you. If that's the case, sorry about the noise. Best, f From Louis.Wicker at noaa.gov Wed Feb 9 22:51:07 2005 From: Louis.Wicker at noaa.gov (Louis Wicker) Date: Wed, 9 Feb 2005 21:51:07 -0600 Subject: [SciPy-user] large arrays ( > 2 gb) in numarray? Message-ID: <85090b136fbb41cc9cbebd0507e04358@noaa.gov> Perry: thanks for the info - will keep my eyes peeled. Have found a work around by allocating memory on the fortran side, but the more elegant soln resides in getting Python and numarray to handle big arrays. Thanks and cheers! Lou ------------------------------------------------------------------------ ---- | Dr. Louis J. Wicker | Research Scientist, National Severe Storms Lab | 1313 Halley Cir, Norman, OK 73069 | E-mail: Louis.Wicker at nssl.noaa.gov | HTTP: www.nssl.noaa.gov/~lwicker | Phone: (405) 366-0416 | Fax: (405) 366-0472 ------------------------------------------------------------------------ ---- From faltet at carabos.com Thu Feb 10 06:04:53 2005 From: faltet at carabos.com (Francesc Altet) Date: Thu, 10 Feb 2005 12:04:53 +0100 Subject: [SciPy-user] large arrays ( > 2 gb) in numarray? In-Reply-To: References: Message-ID: <200502101204.53677.faltet@carabos.com> Hi Lou, If you just need to keep very large arrays and deal with them in slices, you can use the EArray objects in PyTables: from tables import * from numarray import * # creating the container array_b = fileh.createEArray(root, 'array_b', Float64Atom(shape=(2,0,3)), "Very large array", Filters(complevel = 1)) # if you want compression # adding chunks for the large array: for i in range(100): a = array(..., shape=(2,1000*1000*1000,3)) array_b.append(a) # reading chunks of the very large array: for i in range(100): a = array_b[:, 1000*1000*1000*i:1000*1000*1000*(i+1), :] # operations with chunk a after this... You should be able to do this safely in PyTables as it supports 64-bit addressing by default (although, to say the truth, I've never tried at it, at least with EArrays). This is probably not what you want, but just in case. Cheers, A Dimecres 09 Febrer 2005 06:53, Louis Wicker va escriure: > Hello, > > I am new to the list. I have been building a python-fortran ensemble > Kalman filter system for assimilating radar data into convective cloud > models. > > I am running into a big problem that I thought I would ask about. > > I am designing this system for the SGI Altix machines, which is a > Linux64 box with > 15 Gb of memory. > > I ran into the problem that Numeric or Numarray will not allow me to > allocate an array larger than 2 gb. Is this a fundamental limitation > of numarray/Numeric, or > do I need to compile numarray/Numeric in some what to get it to use 64 > bit pointers. For example, here is the failure mode... > > >>> a = numarray.zeros((200,200,50,12,40), typecode='f') > > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/lib/python2.2/site-packages/numarray/numarraycore.py", > line 1200, in zeros > retarr = NumArray(shape=shape, type=type) > libnumarray.error: NA_updateDataPtr: error getting read buffer data ptr > > any ideas? this is running python2.3 and numarray 1.1 > > Thanks. > > Lou Wicker > ------------------------------------------------------------------------ > ---- > > | Dr. Louis J. Wicker > | Research Scientist, National Severe Storms Lab > | 1313 Halley Cir, Norman, OK 73069 > | E-mail: Louis.Wicker at nssl.noaa.gov > | HTTP: www.nssl.noaa.gov/~lwicker > | Phone: (405) 366-0416 > | Fax: (405) 366-0472 > > ------------------------------------------------------------------------ > ---- > > _______________________________________________ > SciPy-user mailing list > SciPy-user at scipy.net > http://www.scipy.net/mailman/listinfo/scipy-user -- >qo< Francesc Altet ? ? http://www.carabos.com/ V ?V C?rabos Coop. V. ??Enjoy Data "" From stephen.walton at csun.edu Thu Feb 10 13:16:33 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Thu, 10 Feb 2005 10:16:33 -0800 Subject: [SciPy-user] lognormal distribution In-Reply-To: <420AB164.7070007@colorado.edu> References: <420AB03E.5090605@csun.edu> <420AB164.7070007@colorado.edu> Message-ID: <420BA501.6030809@csun.edu> Fernando Perez wrote: > I'm not a stats person, so perhaps this one is not enough for you. If > that's the case, sorry about the noise. No, Fernando, ths was what I was looking for, thanks. I have to say, as it is relevant to a previous discussion, that some of the more object-oriented documentation of the stats package is pretty opaque to a new user. For example, help(scipy.stats.distributions) includes the statement: | rvs(self, *args, **kwds) | Random variates of given type. | | *args | ===== | The shape parameter(s) for the distribution (see docstring of the | instance object for more information) Now, I submit a naive new user of Python is not going to know what the "docstring of the instance object" is. Fortunately, scipy.stats.distributions.lognormal? shows it very nicely :-) FYI, it turns out that the distribution of sunspot areas is log-normal, and I'm working on a project to generate a very simple fake sunspot activity cycle. The first simple version, which just generates sunspots which all have the same area, is coded in MATLAB, but I'm promising myself that this project is going to be my first major one done in scipy. From Louis.Wicker at noaa.gov Thu Feb 10 13:27:10 2005 From: Louis.Wicker at noaa.gov (Louis Wicker) Date: Thu, 10 Feb 2005 12:27:10 -0600 Subject: [SciPy-user] large arrays ( > 2 gb) in numarray? Message-ID: Francesc: thanks for the post - I will keep it in mind, but for the application I wanted to build, unfortunately, I need all of the data in memory at once to pass through to a fortran routine for the Kalman filter. Instead, I am allocating the memory on the fortran side, and then reading off of disk into it. Hence my questions about column major ordering, performance, etc. Thanks again for all of your kind help! L ------------------------------------------------------------------------ ---- | Dr. Louis J. Wicker | Research Scientist, National Severe Storms Lab | 1313 Halley Cir, Norman, OK 73069 | E-mail: Louis.Wicker at noaa.gov | HTTP: www.nssl.noaa.gov/~lwicker | Phone: (405) 366-0416 | Fax: (405) 366-0472 | | "Life should NOT be a journey to the grave with the intention of arriving | safely in an attractive and well preserved body, but rather to skid in | sideways, Champagne in one hand - strawberries (and Chocolate) in | the other, body thoroughly used up, totally worn out and screaming | "WOO HOO...What a Ride!" | ------------------------------------------------------------------------ ---- | | "The contents of this message are mine personally and | do not reflect any position of the Government or NOAA." | ------------------------------------------------------------------------ ---- From rspringuel at smcvt.edu Thu Feb 10 14:04:26 2005 From: rspringuel at smcvt.edu (R. Padraic Springuel) Date: Thu, 10 Feb 2005 14:04:26 -0500 Subject: [SciPy-user] optimize.leastsq and uncertianty in results Message-ID: <420BB03A.7030504@smcvt.edu> Is there a way to get the uncertainty in the resultant parameters out of the optimize.leastsq fitting function? I've checked the code and it doesn't seem to list it within the function itself as one of the possible outputs, but maybe I'm missing something. Is there another function to determine these values? -- R. Padraic Springuel From stephen.walton at csun.edu Thu Feb 10 14:38:05 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Thu, 10 Feb 2005 11:38:05 -0800 Subject: [SciPy-user] optimize.leastsq and uncertianty in results In-Reply-To: <420BB03A.7030504@smcvt.edu> References: <420BB03A.7030504@smcvt.edu> Message-ID: <420BB81D.3080904@csun.edu> R. Padraic Springuel wrote: > Is there a way to get the uncertainty in the resultant parameters out > of the optimize.leastsq fitting function? optimize.leastsq? reveals that it can return a dictionary of optional values, among which is the Jacobian matrix fjac at the final step. The diagonal elements of fjac times its transpose can be taken as the squares of the errors in the corresponding coefficients. From dd55 at cornell.edu Thu Feb 10 23:22:39 2005 From: dd55 at cornell.edu (Darren Dale) Date: Thu, 10 Feb 2005 23:22:39 -0500 Subject: [SciPy-user] Question concerning installation Message-ID: <200502102322.39302.dd55@cornell.edu> I am trying to understand a couple issues with installation of scipy, with the hope of getting the gentoo ebuild squared away. I think I have a working installation on Gentoo (installed in the standard way), linking to the atlas-tuned full lapack and blas libraries. I *think* it's working. I have Numeric and numarray installed and linked to atlas, and I edited site.cfg to look in the right places. When I installed scipy, I got the following message: **************************************************************** Using fortran_libraries setup option is depreciated --------------------------------------------------- Use libraries option instead. Yes, scipy_distutils now supports Fortran sources in libraries. **************************************************************** What does this mean? Also, when I run scipy.test() (any level), I get the following two errors: **************************************************************** WARNING: clapack module is empty ----------- See scipy/INSTALL.txt for troubleshooting. Notes: * If atlas library is not found by scipy/system_info.py, then scipy uses flapack instead of clapack. **************************************************************** and **************************************************************** WARNING: cblas module is empty ----------- See scipy/INSTALL.txt for troubleshooting. Notes: * If atlas library is not found by scipy/system_info.py, then scipy uses fblas instead of cblas. **************************************************************** What do these mean? The results of all scipy.test(level=x) were ok. Levels 4 and 5 failed the first trial on check_normal (scipy.stats.morestats.test_morestats.test_anderson). They passed a second trial. The output from system_info.py is listed below, it looks to me like everything is in order. Any help would be appreciated. I think I am close to understanding enough to get this ebuild working on gentoo (thats good advertising for scipy, in my opinion.) Thanks! Darren (sorry for the long post) _pkg_config_info: NOT AVAILABLE agg2_info: ( src_dirs = .:/usr/local/src ) NOT AVAILABLE atlas_blas_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( paths: /usr/lib/liblapack.so ) ( paths: /usr/lib/libblas.so ) ( paths: /usr/lib/libcblas.so ) ( paths: /usr/lib/libatlas.so ) system_info.atlas_blas_info ( include_dirs = /usr/include/atlas:/usr/include ) ( paths: /usr/include/atlas/atlas_cNCmm.h,/usr/include/atlas/atlas_smvN.h,/usr/include/atlas/atlas_smvS.h,/usr/include/atlas/atlas_smvT.h,/usr/include/atlas/atlas_dNCmm.h,/usr/include/atlas/atlas_type.h,/usr/include/atlas/atlas_zmvN.h,/usr/include/atlas/atlas_zmvS.h,/usr/include/atlas/atlas_zmvT.h,/usr/include/atlas/atlas_sNCmm.h,/usr/include/atlas/atlas_zNCmm.h,/usr/include/atlas/atlas_zsysinfo.h,/usr/include/atlas/atlas_ctrsmXover.h,/usr/include/atlas/atlas_ztrsmXover.h,/usr/include/atlas/atlas_csysinfo.h,/usr/include/atlas/atlas_dtrsmXover.h,/usr/include/atlas/atlas_ssysinfo.h,/usr/include/atlas/atlas_cr1.h,/usr/include/atlas/atlas_cmv.h,/usr/include/atlas/atlas_dr1.h,/usr/include/atlas/atlas_dmv.h,/usr/include/atlas/atlas_sr1.h,/usr/include/atlas/atlas_smv.h,/usr/include/atlas/atlas_zr1.h,/usr/include/atlas/atlas_zmv.h,/usr/include/atlas/atlas_strsmXover.h,/usr/include/atlas/atlas_dsysinfo.h,/usr/include/atlas/atlas_cacheedge.h,/usr/include/atlas/atlas_buildinfo.h,/usr/include/atlas/atlas_cmvN.h,/usr/include/atlas/atlas_cmvS.h,/usr/include/atlas/atlas_cmvT.h,/usr/include/atlas/atlas_dmvN.h,/usr/include/atlas/atlas_dmvS.h,/usr/include/atlas/atlas_dmvT.h ) ( paths: /usr/include/atlas ) ( paths: /usr/include/atlas/cblas.h,/usr/include/atlas/cblas.h ) FOUND: libraries = ['lapack', 'blas', 'cblas', 'atlas'] library_dirs = ['/usr/lib'] language = c include_dirs = ['/usr/include/atlas'] atlas_blas_threads_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( paths: /usr/lib/liblapack.so ) ( paths: /usr/lib/libblas.so ) ( paths: /usr/lib/libcblas.so ) ( paths: /usr/lib/libatlas.so ) system_info.atlas_blas_threads_info ( include_dirs = /usr/include/atlas:/usr/include ) ( paths: /usr/include/atlas/atlas_cNCmm.h,/usr/include/atlas/atlas_smvN.h,/usr/include/atlas/atlas_smvS.h,/usr/include/atlas/atlas_smvT.h,/usr/include/atlas/atlas_dNCmm.h,/usr/include/atlas/atlas_type.h,/usr/include/atlas/atlas_zmvN.h,/usr/include/atlas/atlas_zmvS.h,/usr/include/atlas/atlas_zmvT.h,/usr/include/atlas/atlas_sNCmm.h,/usr/include/atlas/atlas_zNCmm.h,/usr/include/atlas/atlas_zsysinfo.h,/usr/include/atlas/atlas_ctrsmXover.h,/usr/include/atlas/atlas_ztrsmXover.h,/usr/include/atlas/atlas_csysinfo.h,/usr/include/atlas/atlas_dtrsmXover.h,/usr/include/atlas/atlas_ssysinfo.h,/usr/include/atlas/atlas_cr1.h,/usr/include/atlas/atlas_cmv.h,/usr/include/atlas/atlas_dr1.h,/usr/include/atlas/atlas_dmv.h,/usr/include/atlas/atlas_sr1.h,/usr/include/atlas/atlas_smv.h,/usr/include/atlas/atlas_zr1.h,/usr/include/atlas/atlas_zmv.h,/usr/include/atlas/atlas_strsmXover.h,/usr/include/atlas/atlas_dsysinfo.h,/usr/include/atlas/atlas_cacheedge.h,/usr/include/atlas/atlas_buildinfo.h,/usr/include/atlas/atlas_cmvN.h,/usr/include/atlas/atlas_cmvS.h,/usr/include/atlas/atlas_cmvT.h,/usr/include/atlas/atlas_dmvN.h,/usr/include/atlas/atlas_dmvS.h,/usr/include/atlas/atlas_dmvT.h ) ( paths: /usr/include/atlas ) ( paths: /usr/include/atlas/cblas.h,/usr/include/atlas/cblas.h ) FOUND: libraries = ['lapack', 'blas', 'cblas', 'atlas'] library_dirs = ['/usr/lib'] language = c include_dirs = ['/usr/include/atlas'] atlas_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( paths: /usr/lib/liblapack.so ) ( paths: /usr/lib/libblas.so ) ( paths: /usr/lib/libcblas.so ) ( paths: /usr/lib/libatlas.so ) ( paths: /usr/lib/liblapack.so ) system_info.atlas_info ( include_dirs = /usr/include/atlas:/usr/include ) ( paths: /usr/include/atlas/atlas_cNCmm.h,/usr/include/atlas/atlas_smvN.h,/usr/include/atlas/atlas_smvS.h,/usr/include/atlas/atlas_smvT.h,/usr/include/atlas/atlas_dNCmm.h,/usr/include/atlas/atlas_type.h,/usr/include/atlas/atlas_zmvN.h,/usr/include/atlas/atlas_zmvS.h,/usr/include/atlas/atlas_zmvT.h,/usr/include/atlas/atlas_sNCmm.h,/usr/include/atlas/atlas_zNCmm.h,/usr/include/atlas/atlas_zsysinfo.h,/usr/include/atlas/atlas_ctrsmXover.h,/usr/include/atlas/atlas_ztrsmXover.h,/usr/include/atlas/atlas_csysinfo.h,/usr/include/atlas/atlas_dtrsmXover.h,/usr/include/atlas/atlas_ssysinfo.h,/usr/include/atlas/atlas_cr1.h,/usr/include/atlas/atlas_cmv.h,/usr/include/atlas/atlas_dr1.h,/usr/include/atlas/atlas_dmv.h,/usr/include/atlas/atlas_sr1.h,/usr/include/atlas/atlas_smv.h,/usr/include/atlas/atlas_zr1.h,/usr/include/atlas/atlas_zmv.h,/usr/include/atlas/atlas_strsmXover.h,/usr/include/atlas/atlas_dsysinfo.h,/usr/include/atlas/atlas_cacheedge.h,/usr/include/atlas/atlas_buildinfo.h,/usr/include/atlas/atlas_cmvN.h,/usr/include/atlas/atlas_cmvS.h,/usr/include/atlas/atlas_cmvT.h,/usr/include/atlas/atlas_dmvN.h,/usr/include/atlas/atlas_dmvS.h,/usr/include/atlas/atlas_dmvT.h ) ( paths: /usr/include/atlas ) ( paths: /usr/include/atlas/cblas.h,/usr/include/atlas/cblas.h ) FOUND: libraries = ['lapack', 'lapack', 'blas', 'cblas', 'atlas'] library_dirs = ['/usr/lib'] language = f77 include_dirs = ['/usr/include/atlas'] atlas_threads_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( paths: /usr/lib/liblapack.so ) ( paths: /usr/lib/libblas.so ) ( paths: /usr/lib/libcblas.so ) ( paths: /usr/lib/libatlas.so ) ( paths: /usr/lib/liblapack.so ) system_info.atlas_threads_info ( include_dirs = /usr/include/atlas:/usr/include ) ( paths: /usr/include/atlas/atlas_cNCmm.h,/usr/include/atlas/atlas_smvN.h,/usr/include/atlas/atlas_smvS.h,/usr/include/atlas/atlas_smvT.h,/usr/include/atlas/atlas_dNCmm.h,/usr/include/atlas/atlas_type.h,/usr/include/atlas/atlas_zmvN.h,/usr/include/atlas/atlas_zmvS.h,/usr/include/atlas/atlas_zmvT.h,/usr/include/atlas/atlas_sNCmm.h,/usr/include/atlas/atlas_zNCmm.h,/usr/include/atlas/atlas_zsysinfo.h,/usr/include/atlas/atlas_ctrsmXover.h,/usr/include/atlas/atlas_ztrsmXover.h,/usr/include/atlas/atlas_csysinfo.h,/usr/include/atlas/atlas_dtrsmXover.h,/usr/include/atlas/atlas_ssysinfo.h,/usr/include/atlas/atlas_cr1.h,/usr/include/atlas/atlas_cmv.h,/usr/include/atlas/atlas_dr1.h,/usr/include/atlas/atlas_dmv.h,/usr/include/atlas/atlas_sr1.h,/usr/include/atlas/atlas_smv.h,/usr/include/atlas/atlas_zr1.h,/usr/include/atlas/atlas_zmv.h,/usr/include/atlas/atlas_strsmXover.h,/usr/include/atlas/atlas_dsysinfo.h,/usr/include/atlas/atlas_cacheedge.h,/usr/include/atlas/atlas_buildinfo.h,/usr/include/atlas/atlas_cmvN.h,/usr/include/atlas/atlas_cmvS.h,/usr/include/atlas/atlas_cmvT.h,/usr/include/atlas/atlas_dmvN.h,/usr/include/atlas/atlas_dmvS.h,/usr/include/atlas/atlas_dmvT.h ) ( paths: /usr/include/atlas ) ( paths: /usr/include/atlas/cblas.h,/usr/include/atlas/cblas.h ) FOUND: libraries = ['lapack', 'lapack', 'blas', 'cblas', 'atlas'] library_dirs = ['/usr/lib'] language = f77 include_dirs = ['/usr/include/atlas'] blas_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( paths: /usr/lib/libblas.so ) FOUND: libraries = ['blas'] library_dirs = ['/usr/lib'] language = f77 blas_opt_info: running build_src building extension "atlas_version" sources adding 'build/src/atlas_version_0x53b6c39a.c' to sources. running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext FOUND: libraries = ['lapack', 'blas', 'cblas', 'atlas'] library_dirs = ['/usr/lib'] language = c define_macros = [('ATLAS_INFO', '"\\"3.6.0\\""')] include_dirs = ['/usr/include/atlas'] blas_src_info: ( src_dirs = .:/usr/local/src ) NOT AVAILABLE boost_python_info: ( src_dirs = .:/usr/local/src ) NOT AVAILABLE dfftw_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( include_dirs = /usr/include/atlas:/usr/include ) NOT AVAILABLE dfftw_threads_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( include_dirs = /usr/include/atlas:/usr/include ) NOT AVAILABLE djbfft_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( include_dirs = /usr/include/atlas:/usr/include ) NOT AVAILABLE fftw_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( include_dirs = /usr/include/atlas:/usr/include ) NOT AVAILABLE fftw_threads_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( include_dirs = /usr/include/atlas:/usr/include ) NOT AVAILABLE freetype2_info: FOUND: libraries = ['freetype', 'z'] define_macros = [('FREETYPE2_INFO', '"\\"9.4.3\\""'), ('FREETYPE2_VERSION_9_4_3', None)] include_dirs = ['/usr/include/freetype2'] gdk_2_info: FOUND: libraries = ['gdk-x11-2.0', 'gdk_pixbuf-2.0', 'm', 'pangoxft-1.0', 'pangox-1.0', 'pango-1.0', 'gobject-2.0', 'gmodule-2.0', 'dl', 'glib-2.0'] extra_link_args = ['-Wl,--export-dynamic'] define_macros = [('GDK_2_INFO', '"\\"2.4.14\\""'), ('GDK_VERSION_2_4_14', None), ('XTHREADS', None), ('_REENTRANT', None), ('XUSE_MTSAFE_API', None)] include_dirs = ['/usr/include/gtk-2.0', '/usr/lib/gtk-2.0/include', '/usr/X11R6/include', '/usr/include/pango-1.0', '/usr/include/freetype2', '/usr/include/freetype2/config', '/usr/include/glib-2.0', '/usr/lib/glib-2.0/include'] gdk_info: FOUND: libraries = ['gdk', 'Xi', 'Xext', 'X11', 'm', 'glib'] library_dirs = ['/usr/X11R6/lib'] define_macros = [('GDK_INFO', '"\\"1.2.10\\""'), ('GDK_VERSION_1_2_10', None)] include_dirs = ['/usr/include/gtk-1.2', '/usr/X11R6/include', '/usr/include/glib-1.2', '/usr/lib/glib/include'] gdk_pixbuf_2_info: FOUND: libraries = ['gdk_pixbuf-2.0', 'm', 'gobject-2.0', 'gmodule-2.0', 'dl', 'glib-2.0'] extra_link_args = ['-Wl,--export-dynamic'] define_macros = [('GDK_PIXBUF_2_INFO', '"\\"2.4.14\\""'), ('GDK_PIXBUF_VERSION_2_4_14', None)] include_dirs = ['/usr/include/gtk-2.0', '/usr/include/glib-2.0', '/usr/lib/glib-2.0/include'] gdk_pixbuf_xlib_2_info: FOUND: libraries = ['gdk_pixbuf_xlib-2.0', 'gdk_pixbuf-2.0', 'm', 'gobject-2.0', 'gmodule-2.0', 'dl', 'glib-2.0'] extra_link_args = ['-Wl,--export-dynamic'] define_macros = [('GDK_PIXBUF_XLIB_2_INFO', '"\\"2.4.14\\""'), ('GDK_PIXBUF_XLIB_VERSION_2_4_14', None)] include_dirs = ['/usr/include/gtk-2.0', '/usr/include/glib-2.0', '/usr/lib/glib-2.0/include'] gdk_x11_2_info: FOUND: libraries = ['gdk-x11-2.0', 'gdk_pixbuf-2.0', 'm', 'pangoxft-1.0', 'pangox-1.0', 'pango-1.0', 'gobject-2.0', 'gmodule-2.0', 'dl', 'glib-2.0'] extra_link_args = ['-Wl,--export-dynamic'] define_macros = [('GDK_X11_2_INFO', '"\\"2.4.14\\""'), ('GDK_X11_VERSION_2_4_14', None), ('XTHREADS', None), ('_REENTRANT', None), ('XUSE_MTSAFE_API', None)] include_dirs = ['/usr/include/gtk-2.0', '/usr/lib/gtk-2.0/include', '/usr/X11R6/include', '/usr/include/pango-1.0', '/usr/include/freetype2', '/usr/include/freetype2/config', '/usr/include/glib-2.0', '/usr/lib/glib-2.0/include'] gtkp_2_info: FOUND: libraries = ['gtk-x11-2.0', 'gdk-x11-2.0', 'atk-1.0', 'gdk_pixbuf-2.0', 'm', 'pangoxft-1.0', 'pangox-1.0', 'pango-1.0', 'gobject-2.0', 'gmodule-2.0', 'dl', 'glib-2.0'] extra_link_args = ['-Wl,--export-dynamic'] define_macros = [('GTKP_2_INFO', '"\\"2.4.14\\""'), ('GTK_VERSION_2_4_14',None), ('XTHREADS', None), ('_REENTRANT', None), ('XUSE_MTSAFE_API', None)] include_dirs = ['/usr/include/gtk-2.0', '/usr/lib/gtk-2.0/include', '/usr/X11R6/include', '/usr/include/atk-1.0', '/usr/include/pango-1.0', '/usr/include/freetype2', '/usr/include/freetype2/config', '/usr/include/glib-2.0', '/usr/lib/glib-2.0/include'] gtkp_x11_2_info: FOUND: libraries = ['gtk-x11-2.0', 'gdk-x11-2.0', 'atk-1.0', 'gdk_pixbuf-2.0', 'm', 'pangoxft-1.0', 'pangox-1.0', 'pango-1.0', 'gobject-2.0', 'gmodule-2.0', 'dl', 'glib-2.0'] extra_link_args = ['-Wl,--export-dynamic'] define_macros = [('GTKP_X11_2_INFO', '"\\"2.4.14\\""'), ('GTK_X11_VERSION_2_4_14', None), ('XTHREADS', None), ('_REENTRANT', None), ('XUSE_MTSAFE_API', None)] include_dirs = ['/usr/include/gtk-2.0', '/usr/lib/gtk-2.0/include', '/usr/X11R6/include', '/usr/include/atk-1.0', '/usr/include/pango-1.0', '/usr/include/freetype2', '/usr/include/freetype2/config', '/usr/include/glib-2.0', '/usr/lib/glib-2.0/include'] lapack_atlas_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( paths: /usr/lib/liblapack.so ) ( paths: /usr/lib/libblas.so ) ( paths: /usr/lib/libcblas.so ) ( paths: /usr/lib/libatlas.so ) ( paths: /usr/lib/liblapack.so ) system_info.lapack_atlas_info ( include_dirs = /usr/include/atlas:/usr/include ) ( paths: /usr/include/atlas/atlas_cNCmm.h,/usr/include/atlas/atlas_smvN.h,/usr/include/atlas/atlas_smvS.h,/usr/include/atlas/atlas_smvT.h,/usr/include/atlas/atlas_dNCmm.h,/usr/include/atlas/atlas_type.h,/usr/include/atlas/atlas_zmvN.h,/usr/include/atlas/atlas_zmvS.h,/usr/include/atlas/atlas_zmvT.h,/usr/include/atlas/atlas_sNCmm.h,/usr/include/atlas/atlas_zNCmm.h,/usr/include/atlas/atlas_zsysinfo.h,/usr/include/atlas/atlas_ctrsmXover.h,/usr/include/atlas/atlas_ztrsmXover.h,/usr/include/atlas/atlas_csysinfo.h,/usr/include/atlas/atlas_dtrsmXover.h,/usr/include/atlas/atlas_ssysinfo.h,/usr/include/atlas/atlas_cr1.h,/usr/include/atlas/atlas_cmv.h,/usr/include/atlas/atlas_dr1.h,/usr/include/atlas/atlas_dmv.h,/usr/include/atlas/atlas_sr1.h,/usr/include/atlas/atlas_smv.h,/usr/include/atlas/atlas_zr1.h,/usr/include/atlas/atlas_zmv.h,/usr/include/atlas/atlas_strsmXover.h,/usr/include/atlas/atlas_dsysinfo.h,/usr/include/atlas/atlas_cacheedge.h,/usr/include/atlas/atlas_buildinfo.h,/usr/include/atlas/atlas_cmvN.h,/usr/include/atlas/atlas_cmvS.h,/usr/include/atlas/atlas_cmvT.h,/usr/include/atlas/atlas_dmvN.h,/usr/include/atlas/atlas_dmvS.h,/usr/include/atlas/atlas_dmvT.h ) ( paths: /usr/include/atlas ) ( paths: /usr/include/atlas/cblas.h,/usr/include/atlas/cblas.h ) FOUND: libraries = ['lapack', 'lapack', 'blas', 'cblas', 'atlas'] library_dirs = ['/usr/lib'] language = f77 include_dirs = ['/usr/include/atlas'] lapack_atlas_threads_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( paths: /usr/lib/liblapack.so ) ( paths: /usr/lib/libblas.so ) ( paths: /usr/lib/libcblas.so ) ( paths: /usr/lib/libatlas.so ) ( paths: /usr/lib/liblapack.so ) system_info.lapack_atlas_threads_info ( include_dirs = /usr/include/atlas:/usr/include ) ( paths: /usr/include/atlas/atlas_cNCmm.h,/usr/include/atlas/atlas_smvN.h,/usr/include/atlas/atlas_smvS.h,/usr/include/atlas/atlas_smvT.h,/usr/include/atlas/atlas_dNCmm.h,/usr/include/atlas/atlas_type.h,/usr/include/atlas/atlas_zmvN.h,/usr/include/atlas/atlas_zmvS.h,/usr/include/atlas/atlas_zmvT.h,/usr/include/atlas/atlas_sNCmm.h,/usr/include/atlas/atlas_zNCmm.h,/usr/include/atlas/atlas_zsysinfo.h,/usr/include/atlas/atlas_ctrsmXover.h,/usr/include/atlas/atlas_ztrsmXover.h,/usr/include/atlas/atlas_csysinfo.h,/usr/include/atlas/atlas_dtrsmXover.h,/usr/include/atlas/atlas_ssysinfo.h,/usr/include/atlas/atlas_cr1.h,/usr/include/atlas/atlas_cmv.h,/usr/include/atlas/atlas_dr1.h,/usr/include/atlas/atlas_dmv.h,/usr/include/atlas/atlas_sr1.h,/usr/include/atlas/atlas_smv.h,/usr/include/atlas/atlas_zr1.h,/usr/include/atlas/atlas_zmv.h,/usr/include/atlas/atlas_strsmXover.h,/usr/include/atlas/atlas_dsysinfo.h,/usr/include/atlas/atlas_cacheedge.h,/usr/include/atlas/atlas_buildinfo.h,/usr/include/atlas/atlas_cmvN.h,/usr/include/atlas/atlas_cmvS.h,/usr/include/atlas/atlas_cmvT.h,/usr/include/atlas/atlas_dmvN.h,/usr/include/atlas/atlas_dmvS.h,/usr/include/atlas/atlas_dmvT.h ) ( paths: /usr/include/atlas ) ( paths: /usr/include/atlas/cblas.h,/usr/include/atlas/cblas.h ) FOUND: libraries = ['lapack', 'lapack', 'blas', 'cblas', 'atlas'] library_dirs = ['/usr/lib'] language = f77 include_dirs = ['/usr/include/atlas'] lapack_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( paths: /usr/lib/liblapack.so ) FOUND: libraries = ['lapack'] library_dirs = ['/usr/lib'] language = f77 lapack_opt_info: /scratch/python/SciPy_complete-0.3.2/scipy_core/scipy_distutils/system_info.py:812: FutureWarning: hex()/oct() of negative int will return a signed string inPython 2.4 and up magic = hex(hash(`config`)) running build_src building extension "atlas_version" sources adding 'build/src/atlas_version_0xe146d5ff.c' to sources. running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext Could not locate executable f77 customize GnuFCompiler customize GnuFCompiler customize GnuFCompiler using build_ext FOUND: libraries = ['lapack', 'lapack', 'blas', 'cblas', 'atlas'] library_dirs = ['/usr/lib'] language = f77 define_macros = [('ATLAS_INFO', '"\\"3.6.0\\""')] include_dirs = ['/usr/include/atlas'] lapack_src_info: ( src_dirs = .:/usr/local/src ) NOT AVAILABLE numarray_info: ( include_dirs = /usr/include/atlas:/usr/include ) FOUND: define_macros = [('NUMARRAY_VERSION', '"\\"1.1.1\\""')] numpy_info: ( include_dirs = /usr/include/atlas:/usr/include ) FOUND: define_macros = [('NUMERIC_VERSION', '"\\"23.7\\""')] sfftw_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( include_dirs = /usr/include/atlas:/usr/include ) NOT AVAILABLE sfftw_threads_info: ( library_dirs = /usr/local/lib:/usr/lib ) ( include_dirs = /usr/include/atlas:/usr/include ) NOT AVAILABLE wx_info: FOUND: libraries = ['wx_gtk2-2.4'] extra_link_args = ['-pthread'] define_macros = [('WX_INFO', '"\\"2.4.2\\""'), ('WX_VERSION_2_4_2', None), ('WX_RELEASE_2_4', None), ('GTK_NO_CHECK_CASTS', None), ('__WXGTK__', None), ('_FILE_OFFSET_BITS', '64'), ('_LARGE_FILES', None)] include_dirs = ['/usr/lib/wx/include/gtk2-2.4'] x11_info: ( library_dirs = /usr/X11R6/lib:/usr/lib ) ( include_dirs = /usr/include/atlas:/usr/include ) ( paths: /usr/X11R6/lib/libX11.so ) ( paths: /usr/include/X11/X.h ) FOUND: libraries = ['X11'] library_dirs = ['/usr/X11R6/lib'] include_dirs = ['/usr/include'] xft_info: FOUND: libraries = ['Xft', 'X11', 'freetype', 'Xrender', 'fontconfig'] define_macros = [('XFT_INFO', '"\\"2.1.2.2\\""'), ('XFT_VERSION_2_1_2_2', None)] include_dirs = ['/usr/X11R6/include', '/usr/include/freetype2', '/usr/include/freetype2/config'] From hecvillaf at yahoo.com Fri Feb 11 12:50:39 2005 From: hecvillaf at yahoo.com (hecvillaf at yahoo.com) Date: Fri, 11 Feb 2005 09:50:39 -0800 (PST) Subject: [SciPy-user] Strange result from "scoreatpercentile" Message-ID: <20050211175040.80005.qmail@web51410.mail.yahoo.com> Hi! I'm trying to get some quartiles from a distribution with scoreatpercentile. But it doesn't match with the values I get from R (which seems pretty correct). Any suggestions? Thanks! -Hector At Python: #----------------------------------# >>> vals = [342, 354, 1, 11, 31, 352, 323, 297, 29, 6, 376, 335, 354, 305, 311, 14, 15, 351, 352, 310, 329, 331, 2, 7, 393, 324, 333, 408, 204, 8, 20, 370, 300, 307, 357, 77, 8, 3, 305, 305, 309, 231, 19, 11, 37, 28, 13, 15, 11, 10, 19, 1, 331, 340, 308, 305, 314, 12, 20, 404, 427, 395, 373, 331, 27, 7, 354, 380, 394, 350, 340, 13, 15, 266, 401, 328, 415, 349, 22, 19, 364, 350, 312, 342, 303, 8, 21] >>> scipy.stats.scoreatpercentile(vals,25) -131.91357142857143 >>> scipy.stats.scoreatpercentile(vals,75) 344.62076923076927 #----------------------------------# At R #----------------------------------# > summary(vals) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.0 19.0 305.0 212.7 349.5 427.0 #----------------------------------# __________________________________ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 From rspringuel at smcvt.edu Fri Feb 11 14:04:18 2005 From: rspringuel at smcvt.edu (R. Padraic Springuel) Date: Fri, 11 Feb 2005 14:04:18 -0500 Subject: [SciPy-user] Re: optimize.leastsq and uncertianty in results In-Reply-To: <20050211042304.C1A643EB9A@www.scipy.com> References: <20050211042304.C1A643EB9A@www.scipy.com> Message-ID: <420D01B2.2050802@smcvt.edu> Okay, as a test of this possibility I tried the following: from scipy import * x = arange(100.) y = x**2 def residuals(parms,y,x): z = parms[0]*x**2 + parms[1]*x + parms[2] err = y - z return err fit = optimize.leastsq(residuals,[0,1,2],args=(y,x),full_output=1) fjac = fit[1].get('fjac') errors = sqrt(diagonal(matrixmultiply(fjac,transpose(fjac)))) print fit[0] print errors Now this should be a simple function to fit, considering there is no noise in the "data" and the fit routine itself runs fairly quickly and returns reasonable results. However, the errors are far from reasonable. Am I missing something, or are the results from leastsq really that uncertain (despite being a good fit)? -- R. Padraic Springuel From stephen.walton at csun.edu Fri Feb 11 14:37:26 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Fri, 11 Feb 2005 11:37:26 -0800 Subject: [SciPy-user] Re: optimize.leastsq and uncertianty in results In-Reply-To: <420D01B2.2050802@smcvt.edu> References: <20050211042304.C1A643EB9A@www.scipy.com> <420D01B2.2050802@smcvt.edu> Message-ID: <420D0976.7080708@csun.edu> R. Padraic Springuel wrote: > Now this should be a simple function to fit, considering there is no > noise in the "data" and the fit routine itself runs fairly quickly and > returns reasonable results. However, the errors are far from reasonable. My mistake. It is the square root of the diagonal elements of the _inverse_ of fjac times its transpose you want; this is called the alpha matrix in most treatments of Levenberg-Marquardt. Of course, with noise-free data the matrix you want to invert is singular. Here's a modification of your script which adds pseudo-random noise to y. The errors look reasonable. The matrix to invert is likely to be singular to the working precision unless the fit parameters are all of the same order of magnitude and there are few of them. If either condition is not true, check the following paper: Hessler, Current, and Ogren 1996, "A new scheme for calculating weights and describing correlations in nonlinear least-squares fits", Computers in Physics, volume 10, pp 186-199, March 1996 issue. from scipy import * x = arange(100.) y = x**2+randn(100) def residuals(parms,y,x): z = parms[0]*x**2 + parms[1]*x + parms[2] err = y - z return err fit = optimize.leastsq(residuals,[0,1,2],args=(y,x),full_output=1) fjac = fit[1].get('fjac') errors = sqrt(diagonal(inverse(matrixmultiply(fjac,transpose(fjac))))) print fit[0] print errors From pajer at iname.com Fri Feb 11 15:14:24 2005 From: pajer at iname.com (Gary) Date: Fri, 11 Feb 2005 15:14:24 -0500 Subject: [SciPy-user] lognormal distribution In-Reply-To: <420AB03E.5090605@csun.edu> References: <420AB03E.5090605@csun.edu> Message-ID: <420D1220.9040102@iname.com> Stephen Walton wrote: > An application question for a change: I need to produce pseudorandom > numbers drawn from a lognormal distribution (see > http://www.itl.nist.gov/div898/handbook/eda/section3/eda3669.htm). > Does anyone have existing code for this in Numeric or numarray? It is interesting to me to see this question. If I understand you correctly, I can say that Speakeasy has what you want. Actually, Speakeasy can produce random numbers from any user-defined distribution, even one that is not analytical. A colleague of mine once (in the early '90s) used that capability in modeling nuclear scintillation detectors. He took a *measured* pulse height distribution from a PMT and used it to generate random numbers that he input into a model of a scintillation crystal. His "Monte Carlo" simulation was 13 lines long. I was intrigued by the usefulness of this feature, so I always have my eye open to see if any other software package has that capability. I haven't searched exhaustively, but I haven't seen it in Matlab (or octave or scilab) or Mathematica or Mathcad. Or any of the usual python packages. Speakeasy (http://www.speakeasy.com) is a lot like Matlab. I once spoke to the guy who runs Speakeasy, and the story he told me was that Speakeasy and Matlab were once one and the same, but split over a disagreement on approach: one faction wanted to enhance flexibility and functionality by building .m files on a core of fortran routines, while the other faction wanted to optimize speed and performance by building lots of fortran components. The former became Matlab, the latter Speakeasy. I have no idea if this story is true. Clearly the marketing people went with Matlab. I just check their web site, and they are still around. They had a following in financial circles and it looks like they are focused there now. -gary From rkern at ucsd.edu Fri Feb 11 17:28:54 2005 From: rkern at ucsd.edu (Robert Kern) Date: Fri, 11 Feb 2005 14:28:54 -0800 Subject: [SciPy-user] lognormal distribution In-Reply-To: <420D1220.9040102@iname.com> References: <420AB03E.5090605@csun.edu> <420D1220.9040102@iname.com> Message-ID: <420D31A6.2040106@ucsd.edu> Gary wrote: > Stephen Walton wrote: > >> An application question for a change: I need to produce pseudorandom >> numbers drawn from a lognormal distribution (see >> http://www.itl.nist.gov/div898/handbook/eda/section3/eda3669.htm). >> Does anyone have existing code for this in Numeric or numarray? > > > It is interesting to me to see this question. > > If I understand you correctly, I can say that Speakeasy has what you > want. Actually, Speakeasy can produce random numbers from any > user-defined distribution, even one that is not analytical. A > colleague of mine once (in the early '90s) used that capability in > modeling nuclear scintillation detectors. He took a *measured* pulse > height distribution from a PMT and used it to generate random numbers > that he input into a model of a scintillation crystal. His "Monte > Carlo" simulation was 13 lines long. > I was intrigued by the usefulness of this feature, so I always have my > eye open to see if any other software package has that capability. I > haven't searched exhaustively, but I haven't seen it in Matlab (or > octave or scilab) or Mathematica or Mathcad. Or any of the usual > python packages. Well, it depends on how tricky the function is. If it's univariate, and you can write out the pdf or cdf as a function, then I believe you can subclass scipy.stats.rv_continuous, and it's rvs() method will numerically invert the cdf to generate it's random numbers. If the function is highly multivariate, you might need to do Markov-Chain Monte Carlo which is implemented by PyMC. If you have a bunch of data points from a continuous distribution, but no functional description, then you can make a kernel density estimate and draw random numbers from that. As of last night, that functionality is in scipy.stats.gaussian_kde. Resampling from discrete data is pretty trivial to handwrite. Is there anything else you need? -- Robert Kern rkern at ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From pajer at iname.com Sat Feb 12 13:31:33 2005 From: pajer at iname.com (Gary) Date: Sat, 12 Feb 2005 13:31:33 -0500 Subject: [SciPy-user] lognormal distribution In-Reply-To: <420D31A6.2040106@ucsd.edu> References: <420AB03E.5090605@csun.edu> <420D1220.9040102@iname.com> <420D31A6.2040106@ucsd.edu> Message-ID: <420E4B85.7050205@iname.com> Robert Kern wrote: > Gary wrote: > >> Stephen Walton wrote: >> >>> An application question for a change: I need to produce >>> pseudorandom numbers drawn from a lognormal distribution (see >>> http://www.itl.nist.gov/div898/handbook/eda/section3/eda3669.htm). >>> Does anyone have existing code for this in Numeric or numarray? >> >> >> >> It is interesting to me to see this question. >> >> If I understand you correctly, I can say that Speakeasy has what you >> want. Actually, Speakeasy can produce random numbers from any >> user-defined distribution, even one that is not analytical. A >> colleague of mine once (in the early '90s) used that capability in >> modeling nuclear scintillation detectors. He took a *measured* pulse >> height distribution from a PMT and used it to generate random numbers >> that he input into a model of a scintillation crystal. His "Monte >> Carlo" simulation was 13 lines long. >> I was intrigued by the usefulness of this feature, so I always have >> my eye open to see if any other software package has that >> capability. I haven't searched exhaustively, but I haven't seen it >> in Matlab (or octave or scilab) or Mathematica or Mathcad. Or any >> of the usual python packages. > > > Well, it depends on how tricky the function is. > > If it's univariate, and you can write out the pdf or cdf as a > function, then I believe you can subclass scipy.stats.rv_continuous, > and it's rvs() method will numerically invert the cdf to generate it's > random numbers. > > If the function is highly multivariate, you might need to do > Markov-Chain Monte Carlo which is implemented by PyMC. > > If you have a bunch of data points from a continuous distribution, but > no functional description, then you can make a kernel density estimate > and draw random numbers from that. As of last night, that > functionality is in scipy.stats.gaussian_kde. > > Resampling from discrete data is pretty trivial to handwrite. > > Is there anything else you need? > World peace and/or longer prison sentences for parole violators? I wasn't aware of the rvs() method. Now I am. I've never heard of kernel density estimate. Now I have. I think I'll try it out on data from the intro physics lab that I teach. The students are seeing histograms for the first time, and they don't like it when the ones they get with their data don't look like the nice bell curves in the book. Thanks, gary From mark at borgerding.net Sat Feb 12 14:54:21 2005 From: mark at borgerding.net (Mark Borgerding) Date: Sat, 12 Feb 2005 14:54:21 -0500 Subject: [SciPy-user] Newbie question Message-ID: <420E5EED.9010204@borgerding.net> I've just started using SciPy. It is really great to have such a collection of good tools. One question: How does one pronounce it? "Skippy" or "Sigh Pie"? From rkern at ucsd.edu Sat Feb 12 15:57:22 2005 From: rkern at ucsd.edu (Robert Kern) Date: Sat, 12 Feb 2005 12:57:22 -0800 Subject: [SciPy-user] Newbie question In-Reply-To: <420E5EED.9010204@borgerding.net> References: <420E5EED.9010204@borgerding.net> Message-ID: <420E6DB2.2050207@ucsd.edu> Mark Borgerding wrote: > I've just started using SciPy. It is really great to have such a > collection of good tools. > > One question: > How does one pronounce it? > > "Skippy" or "Sigh Pie"? I pronounce it "Sigh Pie" and so do most people I've talked to, for example, at the SciPy conferences. -- Robert Kern rkern at ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From drewes at interstice.com Sat Feb 12 20:13:39 2005 From: drewes at interstice.com (Rich Drewes) Date: Sat, 12 Feb 2005 17:13:39 -0800 (PST) Subject: [SciPy-user] problem with kmeans Message-ID: Hello, I was trying to use a simple kmeans test program provided in the docstring for vq.kmeans and I got this error: Traceback (most recent call last): File "kmeanstest.py", line 54, in ? kmeans(whitened,codes) File "/usr/lib/python2.3/site-packages/scipy/cluster/vq.py", line 304, in kmeans guess = take(obs,randint(0,No,k),0) ValueError: invalid input sequence Thinking this looked like an error that I found in the scipy genetic algorithm module (which I reported to this list a few weeks ago), I tried changing line 304 from: guess = take(obs,randint(0,No,k),0) to: guess = take(obs,randint.rvs(0,No,k),0) Now it seems to work, but I am worried. Can anyone suggest what is going on here? Is this a bug arising from a change in how random numbers are handled or am I doing something dumb? I am very new to scipy and not a stats expert. SciPy 0.3.2, Python 2.3. Thank you for SciPy! Rich From rkern at ucsd.edu Sun Feb 13 05:46:47 2005 From: rkern at ucsd.edu (Robert Kern) Date: Sun, 13 Feb 2005 02:46:47 -0800 Subject: [SciPy-user] lognormal distribution In-Reply-To: <420E4B85.7050205@iname.com> References: <420AB03E.5090605@csun.edu> <420D1220.9040102@iname.com> <420D31A6.2040106@ucsd.edu> <420E4B85.7050205@iname.com> Message-ID: <420F3017.9050004@ucsd.edu> Gary wrote: > Robert Kern wrote: >> Is there anything else you need? >> > World peace and/or longer prison sentences for parole violators? Scipy is a large, broad package, but I think this may be outside its purview. > I wasn't aware of the rvs() method. Now I am. > I've never heard of kernel density estimate. Now I have. I think I'll > try it out on data from the intro physics lab that I teach. The > students are seeing histograms for the first time, and they don't like > it when the ones they get with their data don't look like the nice bell > curves in the book. Kernel density estimation is a fairly broad subject all by itself and something of an art rather than science. What I implemented is fairly basic, although that may be just fine for an intro physics lab. There is at least one other Python package for doing KDE that has some more options. Particularly, one problem with Gaussian kernels is that they have infinite support; they are non-zero across the whole, infinite domain. This feature may not be desirable for some data, like those which are constrained to be positive. And for the univariate case, you can sometimes get better (in the area of KDE "better" == "looks nicer to me") with what is called "k-nearest neighbors;" the width of each kernel gets adjusted to be peakier where there are lots of data and flatter where there is less data. KDE is a twiddler's paradise. -- Robert Kern rkern at ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From eric at enthought.com Mon Feb 14 02:03:41 2005 From: eric at enthought.com (eric jones) Date: Mon, 14 Feb 2005 01:03:41 -0600 Subject: [SciPy-user] problem with kmeans In-Reply-To: References: Message-ID: <42104D4D.8000104@enthought.com> That is a change to the random number package that didn't propagate through to the examples. What you did is the correct fix. Please submit a patch to the tracker. thanks, eric Rich Drewes wrote: >Hello, > >I was trying to use a simple kmeans test program provided in the docstring >for vq.kmeans and I got this error: > >Traceback (most recent call last): > File "kmeanstest.py", line 54, in ? > kmeans(whitened,codes) > File "/usr/lib/python2.3/site-packages/scipy/cluster/vq.py", line 304, >in kmeans > guess = take(obs,randint(0,No,k),0) >ValueError: invalid input sequence > >Thinking this looked like an error that I found in the scipy genetic >algorithm module (which I reported to this list a few weeks ago), I tried >changing line 304 from: > > guess = take(obs,randint(0,No,k),0) >to: > guess = take(obs,randint.rvs(0,No,k),0) > >Now it seems to work, but I am worried. Can anyone suggest what is going >on here? Is this a bug arising from a change in how random numbers are >handled or am I doing something dumb? I am very new to scipy and not a >stats expert. > >SciPy 0.3.2, Python 2.3. > >Thank you for SciPy! > >Rich > >_______________________________________________ >SciPy-user mailing list >SciPy-user at scipy.net >http://www.scipy.net/mailman/listinfo/scipy-user > > From nwagner at mecha.uni-stuttgart.de Tue Feb 15 10:23:04 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Tue, 15 Feb 2005 16:23:04 +0100 Subject: [SciPy-user] subscript and superscript in xplt.legend Message-ID: <421213D8.3060108@mecha.uni-stuttgart.de> Hi all, How can I use subscripts and superscripts in xplt.legend The example is \sigma(H^<_m , H_m) xplt.legend(['!s(H^<_m, H_m)'] doesn't work. Nils From elcorto at gmx.net Tue Feb 15 12:04:46 2005 From: elcorto at gmx.net (Steve Schmerler) Date: Tue, 15 Feb 2005 18:04:46 +0100 Subject: [SciPy-user] subscript and superscript in xplt.legend In-Reply-To: <421213D8.3060108@mecha.uni-stuttgart.de> References: <421213D8.3060108@mecha.uni-stuttgart.de> Message-ID: <42122BAE.1090503@gmx.net> Hi I don't know what you want to do with your plots but if you plan to include them in TeX you can export them via xplt.eps (if I remember correctly) with some "normal" labels and put TeX-style formulas as axis labels with the psfrag package (should be part of your TeX system or available at ctan.org). Cheers steve Nils Wagner wrote: > Hi all, > > How can I use subscripts and superscripts in xplt.legend > > The example is > > \sigma(H^<_m , H_m) > > xplt.legend(['!s(H^<_m, H_m)'] doesn't work. > > Nils > > > _______________________________________________ > SciPy-user mailing list > SciPy-user at scipy.net > http://www.scipy.net/mailman/listinfo/scipy-user > > -- There are three types of people in this world: those who make things happen, those who watch things happen and those who wonder what happened. - Mary Kay Ash From nwagner at mecha.uni-stuttgart.de Tue Feb 15 12:18:38 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Tue, 15 Feb 2005 18:18:38 +0100 Subject: [SciPy-user] subscript and superscript in xplt.legend In-Reply-To: <42122BAE.1090503@gmx.net> References: <421213D8.3060108@mecha.uni-stuttgart.de> <42122BAE.1090503@gmx.net> Message-ID: <42122EEE.30902@mecha.uni-stuttgart.de> Steve Schmerler wrote: > Hi > > I don't know what you want to do with your plots but if you plan to > include them in TeX you can export them via xplt.eps (if I remember > correctly) with some "normal" labels and put TeX-style formulas as > axis labels with the psfrag package (should be part of your TeX system > or available at ctan.org). > > Cheers steve > > Nils Wagner wrote: > >> Hi all, >> >> How can I use subscripts and superscripts in xplt.legend >> >> The example is >> >> \sigma(H^<_m , H_m) >> >> xplt.legend(['!s(H^<_m, H_m)'] doesn't work. >> >> Nils >> >> >> _______________________________________________ >> SciPy-user mailing list >> SciPy-user at scipy.net >> http://www.scipy.net/mailman/listinfo/scipy-user >> >> > This works fine (second underscore ) '!s(H^<_m_ ,H_m_)' Nils From drewes at interstice.com Tue Feb 15 12:59:48 2005 From: drewes at interstice.com (Rich Drewes) Date: Tue, 15 Feb 2005 09:59:48 -0800 (PST) Subject: [SciPy-user] parallel ga (genetic algorithm) support Message-ID: Hello, I was thinking of adding parallel evaluation support to the ga module but I noticed there is already a parallel_pop.py in the ga directory. This file makes reference to a number of other python packages that I have never heard of (remote_exec, beowulf) and that are not part of scipy. The code is also formatted strangely (double spaced python code?) There is no clear example program I can find. Does anyone know the status of this work or additional documentation on it? Rich From evelien at ster.kuleuven.ac.be Thu Feb 17 04:12:10 2005 From: evelien at ster.kuleuven.ac.be (Evelien Vanhollebeke) Date: Thu, 17 Feb 2005 10:12:10 +0100 Subject: [SciPy-user] mpfit Message-ID: <42145FEA.7030608@ster.kuleuven.ac.be> Hi scipy-users, I was wondering if anyone was using the mpfit module (http://cars.uchicago.edu/software) . I would really like (need) to use it, but can't get to seem the thing perform as it should be. I am aware of the two messages posted in this mailing list, and changed the two mentioned lines. I am using python 2.3.3. Maybe if someone could share his/her user defined function or some other hints? At first, the program just crashed on the parinfo, which is not really necessary. Now I can get it run (if I don't use the autoderivate=0, then it gets stuck on the "fjac" variable), but as already mentioned, it doesn't iterate. Thanks Evelien From ckkart at hoc.net Thu Feb 17 04:32:13 2005 From: ckkart at hoc.net (Christian Kristukat) Date: Thu, 17 Feb 2005 10:32:13 +0100 Subject: [SciPy-user] mpfit In-Reply-To: <42145FEA.7030608@ster.kuleuven.ac.be> References: <42145FEA.7030608@ster.kuleuven.ac.be> Message-ID: <4214649D.8020804@hoc.net> Hi, Evelien Vanhollebeke wrote: > I was wondering if anyone was using the mpfit module > (http://cars.uchicago.edu/software) . Have you tried optimize.leastsq? This should be very similar to mpfit since it is based on the same fortran code (lmdif/lmder). Christian From rkern at ucsd.edu Thu Feb 17 05:25:36 2005 From: rkern at ucsd.edu (Robert Kern) Date: Thu, 17 Feb 2005 02:25:36 -0800 Subject: [SciPy-user] Infix operators Message-ID: <42147120.2040906@ucsd.edu> There is a disturbingly cool hack now available at the ASPN Python Cookbook site: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122 Given a binary function, you can make something that sort of looks like an infix operator that calls the function. I'll give the code here incorporating some of the suggestions from the comments. # ----%<-------------- class Infix(object): def __init__(self, function): self.function = function def __ror__(self, other): return Infix(lambda x, other=other: self.function(other, x)) def __or__(self, other): return self.function(other) def __call__(self, val1, val2): return self.function(val1, val2) # ----%<-------------- Now one can do things like: from scipy import * dot = Infix(dot) div = Infix(linalg.solve) lsdiv = Infix(linalg.lstsq) conv = Infix(signal.convolve) A |dot| B A |dot| transpose(B) |dot| C A |div| B A |lsdiv| B x |conv| y I'm not entirely sure that I recommend the use of this hack in production code, but when I'm constructing some expressions in ipython, I have found that it is quite annoying to realize halfway through that I need another dot( at the beginning of a line and have to double-check the balancing of parens at the end. -- Robert Kern rkern at ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From evelien at ster.kuleuven.ac.be Thu Feb 17 06:01:57 2005 From: evelien at ster.kuleuven.ac.be (Evelien Vanhollebeke) Date: Thu, 17 Feb 2005 12:01:57 +0100 Subject: [SciPy-user] mpfit In-Reply-To: <4214649D.8020804@hoc.net> References: <42145FEA.7030608@ster.kuleuven.ac.be> <4214649D.8020804@hoc.net> Message-ID: <421479A5.1070305@ster.kuleuven.ac.be> Hi, Yes I've tried that. The problem is, that it doesn't give me what I expect it will. I was using idl to do the same thing, but now I switched to python and with the same input, I expect the same output. Anyway, thanks for the help! Evelien Christian Kristukat wrote: > > Hi, > > Evelien Vanhollebeke wrote: > >> I was wondering if anyone was using the mpfit module >> (http://cars.uchicago.edu/software) . > > > Have you tried optimize.leastsq? This should be very similar to mpfit > since it is based on the same fortran code (lmdif/lmder). > > Christian > > _______________________________________________ > SciPy-user mailing list > SciPy-user at scipy.net > http://www.scipy.net/mailman/listinfo/scipy-user -- Evelien Vanhollebeke evelien.vanhollebeke at ster.kuleuven.ac.be Katholieke Universiteit Leuven http://www.ster.kuleuven.ac.be Instituut voor Sterrenkunde phone: +32-16-32.70.33 Celestijnenlaan 200 B fax: +32-16-32.79.99 B-3001 Leuven From elcorto at gmx.net Thu Feb 17 09:17:20 2005 From: elcorto at gmx.net (Steve Schmerler) Date: Thu, 17 Feb 2005 15:17:20 +0100 Subject: [SciPy-user] mpfit In-Reply-To: <42145FEA.7030608@ster.kuleuven.ac.be> References: <42145FEA.7030608@ster.kuleuven.ac.be> Message-ID: <4214A770.7020001@gmx.net> Evelien Vanhollebeke wrote: > Hi scipy-users, > > I was wondering if anyone was using the mpfit module > (http://cars.uchicago.edu/software) . > I would really like (need) to use it, but can't get to seem the thing > perform as it should be. I am aware of the two messages posted in this > mailing list, that was me :) > and changed the two mentioned lines. I am using python > 2.3.3. Maybe if someone could share his/her user defined function or > some other hints? At first, the program just crashed on the parinfo, > which is not really necessary. Now I can get it run (if I don't use the > autoderivate=0, then it gets stuck on the "fjac" variable), but as > already mentioned, it doesn't iterate. > Unfortunately I don't have my mpfit stuff at hand right now but what I remember doing was something like: ---------------------------------------- import mpfit # read data and prepare 2 data arrays 't' and 'y' .... def func(t, x): """ - the model function - t -- x-axis (data) - x -- parameter array - return y-values at each t """ y_model = ... return y_model # len(t) == len(y_model) = len(y) def residuals(x, t = t, y = y, fjac = None): # I'm not sure about the fjac part, this residual function is # defined according to the example in the mpfit docstring # I think it was 0 status = 0 # or stauts at pos 1? return [status, y - func(t, x)] fit = mpfit.mpfit(residuals, ...) --------------------------------------- I don't remember the parinfo-stuff right now. I wrote a little "wrapper" around mpfit (insert limits in parinfo etc.). Tell me if you want to have a look on this. I also tried leastsq but it's less sophisticated than mpfit. In mpfit (in enorm()) you can replace sqrt(sum(vec*vec)) by sqrt(dot(vec,vec)). This is faster. Cheers steve > Thanks > Evelien > > _______________________________________________ > SciPy-user mailing list > SciPy-user at scipy.net > http://www.scipy.net/mailman/listinfo/scipy-user > > -- There are three types of people in this world: those who make things happen, those who watch things happen and those who wonder what happened. - Mary Kay Ash From evelien at ster.kuleuven.ac.be Thu Feb 17 09:29:56 2005 From: evelien at ster.kuleuven.ac.be (Evelien Vanhollebeke) Date: Thu, 17 Feb 2005 15:29:56 +0100 Subject: [SciPy-user] mpfit In-Reply-To: <4214A770.7020001@gmx.net> References: <42145FEA.7030608@ster.kuleuven.ac.be> <4214A770.7020001@gmx.net> Message-ID: <4214AA64.4000506@ster.kuleuven.ac.be> And how about if you add your own derivatives? In the "help" it read that when you want to use autoderiviate=0 your function should return something like [status,y-func,pderiv], but then, the mpfit function can't handle that, it gives me the following error: ValueError: unpack list of wrong size. The function returns 3 things, the status, the residuals and the derivatives, but mpfit just wants [status,f], so... If it is ok with you, I would like to see your "litte wrapper" around mpfit, maybe it can show me what I am doing wrong... I am also trying the leastsq, but did not suceed to model my data (yet). Thanks! Evelien Steve Schmerler wrote: > > > Evelien Vanhollebeke wrote: > >> Hi scipy-users, >> >> I was wondering if anyone was using the mpfit module >> (http://cars.uchicago.edu/software) . >> I would really like (need) to use it, but can't get to seem the thing >> perform as it should be. I am aware of the two messages posted in >> this mailing list, > > > that was me :) > >> and changed the two mentioned lines. I am using python 2.3.3. Maybe >> if someone could share his/her user defined function or some other >> hints? At first, the program just crashed on the parinfo, which is >> not really necessary. Now I can get it run (if I don't use the >> autoderivate=0, then it gets stuck on the "fjac" variable), but as >> already mentioned, it doesn't iterate. >> > > Unfortunately I don't have my mpfit stuff at hand right now but what I > remember doing was something like: > > ---------------------------------------- > > import mpfit > > # read data and prepare 2 data arrays 't' and 'y' > .... > > def func(t, x): > """ > - the model function > - t -- x-axis (data) > - x -- parameter array > - return y-values at each t > """ > y_model = ... > return y_model > > # len(t) == len(y_model) = len(y) > > def residuals(x, t = t, y = y, fjac = None): > # I'm not sure about the fjac part, this residual function > is # defined according to the example in the mpfit docstring > > # I think it was 0 > status = 0 > > # or stauts at pos 1? > return [status, y - func(t, x)] > > fit = mpfit.mpfit(residuals, ...) > > --------------------------------------- > > I don't remember the parinfo-stuff right now. I wrote a little > "wrapper" around mpfit (insert limits in parinfo etc.). Tell me if you > want to have a look on this. > > I also tried leastsq but it's less sophisticated than mpfit. > > In mpfit (in enorm()) you can replace > > sqrt(sum(vec*vec)) > > by > sqrt(dot(vec,vec)). > This is faster. > > Cheers steve > >> Thanks >> Evelien >> >> _______________________________________________ >> SciPy-user mailing list >> SciPy-user at scipy.net >> http://www.scipy.net/mailman/listinfo/scipy-user >> >> > From grante at visi.com Thu Feb 17 10:30:13 2005 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Feb 2005 09:30:13 -0600 Subject: [SciPy-user] Re: Infix operators In-Reply-To: <42147120.2040906@ucsd.edu> References: <42147120.2040906@ucsd.edu> Message-ID: <20050217153013.GA20434@grante.dsl.visi.com> On Thu, Feb 17, 2005 at 02:25:36AM -0800, Robert Kern wrote: > There is a disturbingly cool hack now available at the ASPN Python > Cookbook site: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122 [...] > A |dot| B > A |dot| transpose(B) |dot| C > A |div| B > A |lsdiv| B > x |conv| y I _love_ it! It's brilliant! It's simple! It's simply brilliant and brilliantly simple! I tried to rate it with 5-stars, but I'd have to register with aspn, and I'm too lazy. I wonder how one would get operator precidence to work in an intuitive way... -- Grant Edwards grante at visi.com From elcorto at gmx.net Thu Feb 17 13:37:03 2005 From: elcorto at gmx.net (Steve Schmerler) Date: Thu, 17 Feb 2005 19:37:03 +0100 Subject: [SciPy-user] mpfit In-Reply-To: <4214AA64.4000506@ster.kuleuven.ac.be> References: <42145FEA.7030608@ster.kuleuven.ac.be> <4214A770.7020001@gmx.net> <4214AA64.4000506@ster.kuleuven.ac.be> Message-ID: <4214E44F.5050202@gmx.net> Evelien Vanhollebeke wrote: > And how about if you add your own derivatives? I don't supply my own derivs so I'm arrfaid I can't help you on this point. > In the "help" it read > that when you want to use autoderiviate=0 your function should return > something like [status,y-func,pderiv], but then, the mpfit function > can't handle that, it gives me the following error: ValueError: unpack > list of wrong size. The function returns 3 things, the status, the > residuals and the derivatives, but mpfit just wants [status,f], so... > If it is ok with you, I would like to see your "litte wrapper" around > mpfit, maybe it can show me what I am doing wrong... OK, no problem, on Monday :) > I am also trying the leastsq, but did not suceed to model my data (yet). leastsq isn't bad and even a little faster since is uses the underlying MINPACK while mpfit in pure (though using Numeric heavily) Python. I use mpfit only because you can easily set parameter bounds. Of course using leastsq you could build some "penalty" into func which causes it to return very high residuals if the parameter array violates any limit etc. > > Thanks! > Evelien > > Steve Schmerler wrote: > >> >> >> Evelien Vanhollebeke wrote: >> >>> Hi scipy-users, >>> >>> I was wondering if anyone was using the mpfit module >>> (http://cars.uchicago.edu/software) . >>> I would really like (need) to use it, but can't get to seem the thing >>> perform as it should be. I am aware of the two messages posted in >>> this mailing list, >> >> >> >> that was me :) >> >>> and changed the two mentioned lines. I am using python 2.3.3. Maybe >>> if someone could share his/her user defined function or some other >>> hints? At first, the program just crashed on the parinfo, which is >>> not really necessary. Now I can get it run (if I don't use the >>> autoderivate=0, then it gets stuck on the "fjac" variable), but as >>> already mentioned, it doesn't iterate. >>> >> >> Unfortunately I don't have my mpfit stuff at hand right now but what I >> remember doing was something like: >> >> ---------------------------------------- >> >> import mpfit >> >> # read data and prepare 2 data arrays 't' and 'y' >> .... >> >> def func(t, x): >> """ >> - the model function >> - t -- x-axis (data) >> - x -- parameter array >> - return y-values at each t >> """ y_model = ... >> return y_model >> >> # len(t) == len(y_model) = len(y) >> >> def residuals(x, t = t, y = y, fjac = None): >> # I'm not sure about the fjac part, this residual function >> is # defined according to the example in the mpfit docstring >> >> # I think it was 0 >> status = 0 >> >> # or stauts at pos 1? >> return [status, y - func(t, x)] >> >> fit = mpfit.mpfit(residuals, ...) >> >> --------------------------------------- >> >> I don't remember the parinfo-stuff right now. I wrote a little >> "wrapper" around mpfit (insert limits in parinfo etc.). Tell me if you >> want to have a look on this. >> >> I also tried leastsq but it's less sophisticated than mpfit. >> >> In mpfit (in enorm()) you can replace >> >> sqrt(sum(vec*vec)) >> >> by >> sqrt(dot(vec,vec)). >> This is faster. >> >> Cheers steve >> >>> Thanks >>> Evelien >>> >>> _______________________________________________ >>> SciPy-user mailing list >>> SciPy-user at scipy.net >>> http://www.scipy.net/mailman/listinfo/scipy-user >>> >>> >> > > _______________________________________________ > SciPy-user mailing list > SciPy-user at scipy.net > http://www.scipy.net/mailman/listinfo/scipy-user > > -- There are three types of people in this world: those who make things happen, those who watch things happen and those who wonder what happened. - Mary Kay Ash From nwagner at mecha.uni-stuttgart.de Fri Feb 18 07:18:14 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Fri, 18 Feb 2005 13:18:14 +0100 Subject: [SciPy-user] Field report of iterative solvers in scipy and a possibly bug in mmio.py Message-ID: <4215DD06.6020309@mecha.uni-stuttgart.de> Hi all, I am wondering if someone is able to reproduce the frequency response function of the test set available through http://www.imtek.uni-freiburg.de/simulation/benchmark/?li=30&nr=38886 with the currently implemented iterative solvers in scipy ? Any field report would be appreciated. Thanks in advance Nils from scipy import * print 'Reading stiffness matrix' K=io.mmread('windscreen.K.mtx') print 'Reading mass matrix' M=io.mmread('windscreen.M.mtx') print 'Reading load vector' f=io.mmread('windscreen.B.mtx') omega = 0.5*arange(1,401) for i in omega: x,info = linalg.bicgstab(K-i**2*M,f) There seems to be a bug in mmio.py Traceback (most recent call last): File "frf.py", line 7, in ? f=io.mmread('windscreen.B.mtx') File "/usr/lib/python2.3/site-packages/scipy/io/mmio.py", line 103, in mmread rows,cols,entries,rep,field,symm = mminfo(source) File "/usr/lib/python2.3/site-packages/scipy/io/mmio.py", line 65, in mminfo assert len(line)==2,`line` AssertionError: ['22692', '1', '22692'] From elcorto at gmx.net Mon Feb 21 10:54:46 2005 From: elcorto at gmx.net (Steve Schmerler) Date: Mon, 21 Feb 2005 16:54:46 +0100 Subject: [SciPy-user] mpfit In-Reply-To: <4214E44F.5050202@gmx.net> References: <42145FEA.7030608@ster.kuleuven.ac.be> <4214A770.7020001@gmx.net> <4214AA64.4000506@ster.kuleuven.ac.be> <4214E44F.5050202@gmx.net> Message-ID: <421A0446.3050602@gmx.net> Here the call-mpfit stuff. Maybe this helps. Cheers, Steve -- There are three types of people in this world: those who make things happen, those who watch things happen and those who wonder what happened. - Mary Kay Ash -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: mpfit_wr.py URL: From evelien at ster.kuleuven.ac.be Tue Feb 22 03:05:51 2005 From: evelien at ster.kuleuven.ac.be (Evelien Vanhollebeke) Date: Tue, 22 Feb 2005 09:05:51 +0100 Subject: [SciPy-user] mpfit In-Reply-To: <421A0446.3050602@gmx.net> References: <42145FEA.7030608@ster.kuleuven.ac.be> <4214A770.7020001@gmx.net> <4214AA64.4000506@ster.kuleuven.ac.be> <4214E44F.5050202@gmx.net> <421A0446.3050602@gmx.net> Message-ID: <421AE7DF.9060404@ster.kuleuven.ac.be> Thanks! Evelien Steve Schmerler wrote: > Here the call-mpfit stuff. Maybe this helps. > > Cheers, Steve > >------------------------------------------------------------------------ > >#!/usr/bin/env python ># -*- coding: utf-8 -*- > ># here are the essential parts of a small function which calls mpfit ># ================================================================== > > ># [...] > > ># assuming you have the data arrays 't' and 'y' in the namespace >def residuals(x, y = y, t = t, fjac = None, err = None): > """ > y-func(t,x) - array with residuals > """ > status = 0 > return [status, array(y-func(t,x), 'd')] > >residualFunction = residuals > > >def parametersInfos(initial_guess, limits, fixed, max_steps = None): > """ > initial_guess -- array of len(x), the starting point > limits -- n x 2 list of lists or array, n is the number of parameters to be fitted (== len(x)), > limits = [[l, u], ..., [l, u]] where limits[i] contains the lower (l) and upper (u) bounds of the i-th parameter > fixed -- a list of tuples of the form [(parameter_index,value),(),...,()] telling that parameter x[parameter_index] is > to be held constant at 'value' > max_steps -- list of len(x), if max_steps[i] != 0: max iteration step length for x[i] > """ > # no parameter bounds > if (limits == None): > parameter_infos = [{'mpside':0} for i in range(len(initial_guess))] > else: > parameter_infos = [{'limited':[1,1],'limits':limits[i],'mpside':0} for i in range(len(initial_guess))] > for j in range(len(parameter_infos)): > # enter start values in dictionary 'parameter_infos' > parameter_infos[j]['value'] = initial_guess[j] > if max_steps: > # set max iteration step for parameter j; max_step[j] = 0 means no max step > parameter_infos[j]['mpmaxstep'] = max_steps[j] > # change 'parameter_infos' - entry if a parameter is fixed > if (fixed != None): > for f in fixed: > # f is a tuple > i = f[0] > parameter_infos[i] = {'fixed':1} > parameter_infos[i]['value'] = float(f[1]) > return parameter_infos > > ># for printing the termination status of mpfit >mpfit_messages = {0: "Improper input parameters in mpfit.", > 1: "Both actual and predicted relative reductions in the sum of squares are at most ftol.", > 2: "Relative error between two consecutive iterates is at most xtol.", > 3: "Conditions for status = 1 and status = 2 both hold:\n\ > Both actual and predicted relative reductions in the sum of squares are at most ftol.\n\ > Relative error between two consecutive iterates is at most xtol.", > 4: "The cosine of the angle between fvec and any column of the jacobian is at most gtol in absolute value.", > 5: "The maximum number of iterations has been reached.", > 6: "ftol is too small. No further reduction in the sum of squares is possible.", > 7: "xtol is too small. No further improvement in the approximate solution x is possible.", > 8: "gtol is too small. fvec is orthogonal to the columns of the jacobian to machine precision."} > > > >parameter_infos = parametersInfos(initial_guess, limits, fixed, max_steps = max_steps) >fit = mpfit.mpfit(residualFunction, parinfo=parameter_infos, quiet=1, ftol=1e-15, xtol=1e-15, gtol=1e-15, maxiter=niter) > > >------------------------------------------------------------------------ > >_______________________________________________ >SciPy-user mailing list >SciPy-user at scipy.net >http://www.scipy.net/mailman/listinfo/scipy-user > > From nwagner at mecha.uni-stuttgart.de Tue Feb 22 03:44:12 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Tue, 22 Feb 2005 09:44:12 +0100 Subject: [SciPy-user] Bug in io.mmread Message-ID: <421AF0DC.2040207@mecha.uni-stuttgart.de> Hi all, I am reporting a bug in io.mmread. mmread in Matlab can handle the input file. The test file is attached Traceback (most recent call last): File "benchmark.py", line 2, in ? f = io.mmread('windscreen.B.mtx.gz') File "/usr/lib/python2.3/site-packages/scipy/io/mmio.py", line 103, in mmread rows,cols,entries,rep,field,symm = mminfo(source) File "/usr/lib/python2.3/site-packages/scipy/io/mmio.py", line 65, in mminfo assert len(line)==2,`line` AssertionError: ['22692', '1', '22692'] Nils -------------- next part -------------- A non-text attachment was scrubbed... Name: benchmark.py Type: text/x-python Size: 57 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: windscreen.B.mtx.gz Type: application/x-tar Size: 3476 bytes Desc: not available URL: From nwagner at mecha.uni-stuttgart.de Tue Feb 22 03:50:17 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Tue, 22 Feb 2005 09:50:17 +0100 Subject: [SciPy-user] Umfpack and scipy Message-ID: <421AF249.6090300@mecha.uni-stuttgart.de> Hi all, Is it possible to use UMFPACK (scipy/Lib/sparse/UMFPACK2.2) within scipy ? A small example would be appreciated. BTW, the latest version is 4.4 http://www.cise.ufl.edu/research/sparse/umfpack/ Any comment ? Nils From rkern at ucsd.edu Tue Feb 22 14:37:00 2005 From: rkern at ucsd.edu (Robert Kern) Date: Tue, 22 Feb 2005 11:37:00 -0800 Subject: [SciPy-user] Umfpack and scipy In-Reply-To: <421AF249.6090300@mecha.uni-stuttgart.de> References: <421AF249.6090300@mecha.uni-stuttgart.de> Message-ID: <421B89DC.4080208@ucsd.edu> Nils Wagner wrote: > Hi all, > > Is it possible to use UMFPACK (scipy/Lib/sparse/UMFPACK2.2) within scipy ? There are no UMFPACK wrappers in CVS scipy, now. It is certainly possible to write UMFPACK wrappers that use scipy.sparse matrices. -- Robert Kern rkern at ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From novak at ucolick.org Tue Feb 22 18:27:30 2005 From: novak at ucolick.org (Greg Novak) Date: Tue, 22 Feb 2005 15:27:30 -0800 Subject: [SciPy-user] Numeric Documentation Message-ID: <20050222232730.GA9466@dionysus.ucolick.org> Can someone please post the Numeric Documentation PDF file next to the HTML version here:http://numeric.scipy.org/. The HTML documetation renders illegibly in certain spots for me (text is placed on top of other text). I had been getting it from http://www.pfdubois.com/numpy/ but that site's been taken down. Thanks! Greg From dd55 at cornell.edu Tue Feb 22 18:45:40 2005 From: dd55 at cornell.edu (Darren Dale) Date: Tue, 22 Feb 2005 18:45:40 -0500 Subject: [SciPy-user] Numeric Documentation In-Reply-To: <20050222232730.GA9466@dionysus.ucolick.org> References: <20050222232730.GA9466@dionysus.ucolick.org> Message-ID: <200502221845.40484.dd55@cornell.edu> I also wanted to suggest that numeric.scipy.org should have a link to the sourceforge download page. On Tuesday 22 February 2005 06:27 pm, Greg Novak wrote: > Can someone please post the Numeric Documentation PDF file next to the > HTML version here:http://numeric.scipy.org/. The HTML documetation > renders illegibly in certain spots for me (text is placed on top of > other text). > > I had been getting it from http://www.pfdubois.com/numpy/ but that > site's been taken down. > > Thanks! > Greg > > _______________________________________________ > SciPy-user mailing list > SciPy-user at scipy.net > http://www.scipy.net/mailman/listinfo/scipy-user -- Darren From Fernando.Perez at colorado.edu Tue Feb 22 18:51:37 2005 From: Fernando.Perez at colorado.edu (Fernando Perez) Date: Tue, 22 Feb 2005 16:51:37 -0700 Subject: [SciPy-user] Numeric Documentation In-Reply-To: <20050222232730.GA9466@dionysus.ucolick.org> References: <20050222232730.GA9466@dionysus.ucolick.org> Message-ID: <421BC589.20004@colorado.edu> Greg Novak wrote: > Can someone please post the Numeric Documentation PDF file next to the > HTML version here:http://numeric.scipy.org/. The HTML documetation > renders illegibly in certain spots for me (text is placed on top of > other text). Long ago I fixed that HTML by hand for personal use. I've put it up here: http://amath.colorado.edu/faculty/fperez/python/numpy-doc/ Travis, feel free to wget that whole dir and prop it up on the new numeric site. I think this HTML version has most (all?) the problems in the original fixed. Best, f ps. I can't find a copy of the PDF, so I didn't put it up there. From aisaac at american.edu Tue Feb 22 23:59:25 2005 From: aisaac at american.edu (Alan G Isaac) Date: Tue, 22 Feb 2005 23:59:25 -0500 (Eastern Standard Time) Subject: [SciPy-user] Numeric Documentation In-Reply-To: <20050222232730.GA9466@dionysus.ucolick.org> References: <20050222232730.GA9466@dionysus.ucolick.org> Message-ID: On Tue, 22 Feb 2005, Greg Novak apparently wrote: > Can someone please post the Numeric Documentation PDF file next to the > HTML version here:http://numeric.scipy.org/. The HTML documetation > renders illegibly in certain spots for me (text is placed on top of > other text). This reminds me to mention: reST now has rst2mathml in the "sandbox", thanks to Jens J?rgen Mortenson. (This allows raw LaTeX code in reST documents to be converted to MathML.) Cheers, Alan Isaac From nwagner at mecha.uni-stuttgart.de Wed Feb 23 04:28:09 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Wed, 23 Feb 2005 10:28:09 +0100 Subject: [SciPy-user] Pade approximants Message-ID: <421C4CA9.2070302@mecha.uni-stuttgart.de> Hi all, Has someone written a wrapper for the FORTRAN subroutine pade which is available through http://lib-www.lanl.gov/numerical/bookfpdf/f5-12.pdf It would be nice to have a function called pade in scipy :-) . Any comments or suggestions ? Nils From nwagner at mecha.uni-stuttgart.de Wed Feb 23 07:40:25 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Wed, 23 Feb 2005 13:40:25 +0100 Subject: [SciPy-user] derivative Message-ID: <421C79B9.7070801@mecha.uni-stuttgart.de> Hi all, Is it somehow possible to improve the accuracy of derivative ? A small example is attached. from scipy import * def func(x): return exp(2*x) for i in arange(1,6): print i,' derivative of exp(2*x) at x=0',derivative(func,0.0,0.01,i,order=7),'exact',2**i Any suggestion ? Nils From stephen.walton at csun.edu Wed Feb 23 09:02:04 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Wed, 23 Feb 2005 06:02:04 -0800 Subject: [SciPy-user] derivative In-Reply-To: <421C79B9.7070801@mecha.uni-stuttgart.de> References: <421C79B9.7070801@mecha.uni-stuttgart.de> Message-ID: <421C8CDC.9010605@csun.edu> Nils Wagner wrote: > Hi all, > > Is it somehow possible to improve the accuracy of derivative ? Higher order? from scipy import * def func(x): return exp(2*x) for i in arange(1,6): d=derivative(func,0.0,dx,i,order=9) print i,' derivative of exp(2*x) at x=0',d,'exact',2**i print ' rel error %e' % (d/2**i - 1) Changing the order to 9 improves the accuracy of the 6th derivative from 1e-4 to 3e-7. From nwagner at mecha.uni-stuttgart.de Wed Feb 23 09:10:31 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Wed, 23 Feb 2005 15:10:31 +0100 Subject: [SciPy-user] derivative In-Reply-To: <421C8CDC.9010605@csun.edu> References: <421C79B9.7070801@mecha.uni-stuttgart.de> <421C8CDC.9010605@csun.edu> Message-ID: <421C8ED7.8070908@mecha.uni-stuttgart.de> Stephen Walton wrote: > Nils Wagner wrote: > >> Hi all, >> >> Is it somehow possible to improve the accuracy of derivative ? > > > Higher order? > > from scipy import * > > def func(x): > return exp(2*x) > > for i in arange(1,6): > d=derivative(func,0.0,dx,i,order=9) > print i,' derivative of exp(2*x) at x=0',d,'exact',2**i > print ' rel error %e' % (d/2**i - 1) > > Changing the order to 9 improves the accuracy of the 6th derivative > from 1e-4 to 3e-7. > The problem is that I need very accurate results, since I want to use them as an input of cof in SUBROUTINE pade (see my previous E-mail Pade Approximants). cof contains the leading terms of the power series expansion of a function. Nils > _______________________________________________ > SciPy-user mailing list > SciPy-user at scipy.net > http://www.scipy.net/mailman/listinfo/scipy-user From stephen.walton at csun.edu Wed Feb 23 12:34:13 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Wed, 23 Feb 2005 09:34:13 -0800 Subject: [SciPy-user] derivative In-Reply-To: <421C8ED7.8070908@mecha.uni-stuttgart.de> References: <421C79B9.7070801@mecha.uni-stuttgart.de> <421C8CDC.9010605@csun.edu> <421C8ED7.8070908@mecha.uni-stuttgart.de> Message-ID: <421CBE95.3080102@csun.edu> Numerical derivatives are limited in accuracy by their very nature. I don't know very much about Pade computations, I'm afraid, But, if the code you need the derivative of is in C or Fortran, you might try one of the automatic differentation codes out there. The basic idea is that, since any computation on a real computer is composed of elementary operations with analytic derivatives, repeated automatic application of the chain rule results in a derivative which is accurate to machine precision. Of course, these codes will only produce a first or second derivative in my experience, not a sixth. Do you need sixth derivatives? From gerard.vermeulen at grenoble.cnrs.fr Wed Feb 23 12:46:30 2005 From: gerard.vermeulen at grenoble.cnrs.fr (Gerard Vermeulen) Date: Wed, 23 Feb 2005 18:46:30 +0100 Subject: [SciPy-user] ANN: PyQwt-4.2 released Message-ID: <20050223184630.4e15b424.gerard.vermeulen@grenoble.cnrs.fr> What is PyQwt? - it is a set of Python bindings for the Qwt C++ class library which extends the Qt framework with widgets for scientific, engineering and financial applications. It provides a widget to plot 2-dimensional data and various widgets to display and control bounded or unbounded floating point values. - it requires and extends PyQt, a set of Python bindings for Qt. - it supports the use of PyQt, Qt, Qwt, the Numerical Python extensions (either Numeric, or numarray or both) and optionally SciPy in a GUI Python application or in an interactive Python session. - it runs on POSIX, MacOS/X and Windows platforms (practically any platform supported by Qt and Python). The home page of PyQwt is http://pyqwt.sourceforge.net. PyQwt-4.2 is a maintenance release to keep up with the recent releases of PyQt-3.14 and its code generator SIP-4.2. PyQwt-4.2 supports: 1. Python-2.4 downto -2.1. 2. PyQt-3.14 downto -3.10. 3. SIP-4.2 downto -4.0, and SIP-3.11 downto -3.10. 4. Qt-3.3.4 downto -2.3.0. 5. Qwt-4.2.0. Have fun -- Gerard Vermeulen From nwagner at mecha.uni-stuttgart.de Wed Feb 23 13:50:02 2005 From: nwagner at mecha.uni-stuttgart.de (Nils Wagner) Date: Wed, 23 Feb 2005 19:50:02 +0100 Subject: [SciPy-user] derivative In-Reply-To: <421CBE95.3080102@csun.edu> References: <421C79B9.7070801@mecha.uni-stuttgart.de> <421C8CDC.9010605@csun.edu> <421C8ED7.8070908@mecha.uni-stuttgart.de> <421CBE95.3080102@csun.edu> Message-ID: On Wed, 23 Feb 2005 09:34:13 -0800 Stephen Walton wrote: > Numerical derivatives are limited in accuracy by their >very nature. I don't know very much about Pade >computations, I'm afraid, But, if the code you need the >derivative of is in C or Fortran, you might try one of >the automatic differentation codes out there. The basic >idea is that, since any computation on a real computer is >composed of elementary operations with analytic >derivatives, repeated automatic application of the chain >rule results in a derivative which is accurate to machine >precision. Of course, these codes will only produce a >first or second derivative in my experience, not a sixth. > Do you need sixth derivatives? This depends on the order of the Taylor series expansion. pade(an,8) is quite common in approximating the matrix exponential. pade(an, m) Given Taylor series coefficients in an, return a Pade approximation to the function as the ratio of two polynomials p / q where the order of q is m. Nils > > _______________________________________________ > SciPy-user mailing list > SciPy-user at scipy.net > http://www.scipy.net/mailman/listinfo/scipy-user From jefferph at xsmail.com Thu Feb 24 09:02:42 2005 From: jefferph at xsmail.com (Paul Jefferson) Date: Thu, 24 Feb 2005 14:02:42 +0000 Subject: [SciPy-user] Eigenvalues for bandstructures problem... Message-ID: Hi, I have been using the linalg module in scipy (as well as the LinearAlgebra module in Numeric, and the Linear_Algebra module in numarray) to calculate the eigenvalues of a 4x4 hamiltonian matrix that calculates semiconductor bandstructures. A variable k is cycled through changing the elements of the matrix and the eigenvalues are obtained for each value of k. Each band is defined by one eigenvalue (0,1,2 or 3 in the returned array) for all k. On plotting the bands as a function of k. I noticed that the eigenvalues swap over at certain values of (+/-) k (best seen in the attached figure). I was wondering if anybody knew of this problem using the linalg package? (I don't have the same problem with octave (which I think also uses atlas)). If anyone can throw any light on this problem it would be much appreciated. Best Regards, Paul Jefferson. -------------- next part -------------- A non-text attachment was scrubbed... Name: bands.pdf Type: application/pdf Size: 29443 bytes Desc: not available URL: From joe at enthought.com Thu Feb 24 10:10:39 2005 From: joe at enthought.com (Joe Cooper) Date: Thu, 24 Feb 2005 09:10:39 -0600 Subject: [SciPy-user] SciPy.org and Enthought.com scheduled downtime today at ~12 CST Message-ID: <421DEE6F.2080106@enthought.com> Hi all, Both SciPy.org and Enthought.com and all of the services that they host will be taken offline today at around noon CST. We are moving upstairs today and taking the servers with us. SBC willing, the servers will be out of service for no more than an hour or so. Anyway, if you're planning a check-in for lunchtime today, hold off a while, or get it in before then. ;-) Thanks! From rspringuel at smcvt.edu Fri Feb 25 18:18:33 2005 From: rspringuel at smcvt.edu (R. Padraic Springuel) Date: Fri, 25 Feb 2005 18:18:33 -0500 Subject: [SciPy-user] Partial Derivatives Message-ID: <421FB249.1030503@smcvt.edu> Is there a way to use the "derivative" function to take a partial derivative? What if one of the inputs is a list of numbers instead of a single number? Example: def y(x,p): return p[0] + p[1]*x + p[2]*x**2 I can get the derivative with respect to x fairly easily with the following: derivative(y, 3, args=([[0, 0, 1]]) where the numbers can be arbitrarily replaced. However I can't seem to get the derivative with respect to say p[0] or any other member of p. I keep getting a TypeError regarding the number of arguments for y. Any suggestions? -- R. Padraic Springuel From stephen.walton at csun.edu Fri Feb 25 18:41:08 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Fri, 25 Feb 2005 15:41:08 -0800 Subject: [SciPy-user] Partial Derivatives In-Reply-To: <421FB249.1030503@smcvt.edu> References: <421FB249.1030503@smcvt.edu> Message-ID: <1109374868.16735.2.camel@freyer.sfo.csun.edu> On Fri, 2005-02-25 at 18:18 -0500, R. Padraic Springuel wrote: > Is there a way to use the "derivative" function to take a partial > derivative? Looking at the source for derivative (derivative?? in IPython) shows the following line as relevant: val += weights[k]*func(x0+(k-ho)*dx,*args) So it looks like derivative is hard wired to take the derivative with respect to the first argument of 'func' only. > What if one of the inputs is a list of numbers instead of a > single number? In [31]: derivative(y,array([7,4]),args=[[1,4,3]]) Out[31]: NumPy array, format: long [ 46. 28.] :-) From oliphant at ee.byu.edu Fri Feb 25 18:56:21 2005 From: oliphant at ee.byu.edu (Travis Oliphant) Date: Fri, 25 Feb 2005 16:56:21 -0700 Subject: [SciPy-user] Partial Derivatives In-Reply-To: <421FB249.1030503@smcvt.edu> References: <421FB249.1030503@smcvt.edu> Message-ID: <421FBB25.5050308@ee.byu.edu> R. Padraic Springuel wrote: > Is there a way to use the "derivative" function to take a partial > derivative? What if one of the inputs is a list of numbers instead of > a single number? > > Example: > def y(x,p): > return p[0] + p[1]*x + p[2]*x**2 > > I can get the derivative with respect to x fairly easily with the > following: > > derivative(y, 3, args=([[0, 0, 1]]) > > where the numbers can be arbitrarily replaced. However I can't seem > to get the derivative with respect to say p[0] or any other member of > p. I keep getting a TypeError regarding the number of arguments for > y. Any suggestions? derivative is hard-wired for the first argument. This could be changed relatively easily and is a nice suggestion. In the mean-time, you can define intermediate functions: def y2(p0,x,p1,p2): return y(x,[p0,p1,p2]) def y3(p1, x, p0, p2): return y(x,[p0,p1,p2]) def y4(p2, x, p0, p1): return y(x, [p0, p1, p2]) and use derivative on those functions. -Travis From aisaac at american.edu Fri Feb 25 22:29:37 2005 From: aisaac at american.edu (Alan G Isaac) Date: Fri, 25 Feb 2005 22:29:37 -0500 (Eastern Standard Time) Subject: [SciPy-user] Partial Derivatives In-Reply-To: <421FB249.1030503@smcvt.edu> References: <421FB249.1030503@smcvt.edu> Message-ID: On Fri, 25 Feb 2005, "R. Padraic Springuel" apparently wrote: > Is there a way to use the "derivative" function to take a partial > derivative? Is scipy.optimize.approx_fprime serviceable here? I notice it fails to account for epsilon != (x+espilon)-x so the line grad[k] = (apply(f,(xk+ei,)+args) - f0)/epsilon should I believe be changed to grad[k] = (apply(f,(xk+ei,)+args) - f0)/((xk[k]+epsilon)-xk[k]) to improve accuracy. Of course this still uses 'apply' which is deprecated since Python 2.3. (I don't claim to know if this is a good idea, but it reputedly slows things down: http://www.python.org/doc/2.3.3/lib/non-essential-built-in-funcs.html ) Also, just out of curiosity since we're here: why the strange argument order (function 2nd) for the gradient (and hessian) here? fwiw, Alan Isaac From gerard.vermeulen at grenoble.cnrs.fr Sun Feb 27 10:06:42 2005 From: gerard.vermeulen at grenoble.cnrs.fr (Gerard Vermeulen) Date: Sun, 27 Feb 2005 16:06:42 +0100 Subject: [SciPy-user] ANN: PyQwt3D-0.1 released Message-ID: <20050227160642.1c671444.gerard.vermeulen@grenoble.cnrs.fr> What is PyQwt3D? - it is a set of Python bindings for the QwtPlot3D C++ class library which extends the Qt framework with widgets for 3D data visualization. PyQwt3D inherits the snappy feel from QwtPlot3D. The examples at http://pyqwt.sourceforge.net/pyqwt3d-examples.html show how easy it is to make a 3D plot and how to save a 3D plot to an image or an (E)PS/PDF file. - it requires and extends PyQt, a set of Python bindings for Qt. - it supports the use of PyQt, Qt, Qwt, the Numerical Python extensions (either Numeric, or numarray or both) and optionally SciPy in a GUI Python application or in an interactive Python session. - it runs on POSIX, MacOS/X and Windows platforms (practically any platform supported by Qt and Python). The home page of PyQwt3D is http://pyqwt.sourceforge.net. PyQwt3D-0.1 supports: 1. Python-2.4 downto -2.3. 2. PyQt-3.14 downto -3.12. 3. SIP-4.2 downto -4.0, but SIP-4.2 is recommended. PyQwt3D does *not* support SIP-3.x (I tried, but failed). 4. Qt-3.3.4 downto -2.3.0. 5. QwtPlot3D-0.2.4-beta. Have fun -- Gerard Vermeulen