7 Feb 2002 11:03
7 Feb 2002 11:11
Re: Simulating white noise with Numpy
Jon Saenz <jsaenz <at> wm.lc.ehu.es>
2002-02-07 10:11:55 GMT
2002-02-07 10:11:55 GMT
import RandomArray mean=0.0 stdev=1.0 RandomArray.normal(mean,stdev,shape=ReturnFloat) Manual of Numpy, chapter 17, page 97. Edition October 200. Jon Saenz. | Tfno: +34 946012445 Depto. Fisica Aplicada II | Fax: +34 944648500 Facultad de Ciencias. \\ Universidad del Pais Vasco \\ Apdo. 644 \\ 48080 - Bilbao \\ SPAIN On Thu, 7 Feb 2002, Nils Wagner wrote: > Hi, > > How can I simulate a stationary, white noise, Gaussian random process > (zero mean and unit variance) with Numpy ? > > Nils > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion <at> lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/numpy-discussion >
14 Feb 2002 19:00
Proposal, recoded average.
Paul F. Dubois <paul <at> pfdubois.com>
2002-02-14 18:00:16 GMT
2002-02-14 18:00:16 GMT
I recoded the new average function in both Numeric and MA. This version
ensures that in the returned=1 case the weights returned will be of the
same shape as the average. The new version is in CVS and labeled as
21.0b2.
The average now allows weights that, rather than having to be the same
size as the input, can be the same size as the input's axis'th
dimension. This relieves the user of the rather tricky code needed to
make an array of a given shape broadcasting a vector along a certain
axis. This is a relatively frequent need and so I will write a separate
routine for it soon. My proposed calling sequence is:
def broadcast(v, axis=0, s)
"""Returns an array of the type of v and the shape s, such that
setting the axis'th
subscript to j results in an array whose values are all v[j].
"""
Comments about this idea or the way I explain it would be welcome.
15 Feb 2002 03:24
subsampling
Mathew Yeates <mathew <at> fugue.jpl.nasa.gov>
2002-02-15 02:24:25 GMT
2002-02-15 02:24:25 GMT
Hi- Maybe this is a dumb question .... but.... how can I take a matrix and subsample it down to an arbitrary size? It seems that using slices is limited to constant integer step sizes while, if I'm converting between arbitrary sizes, I would like to subsample at a nonuniform rate. Am I missing something? Mathew
15 Feb 2002 03:44
subsampling
Charles G Waldman <cgw <at> alum.mit.edu>
2002-02-15 02:44:18 GMT
2002-02-15 02:44:18 GMT
Mathew Yeates writes:
> how can I take a matrix and subsample it down to
> an arbitrary size? It seems that using slices is
> limited to constant integer step sizes while, if
> I'm converting between arbitrary sizes, I would like
> to subsample at a nonuniform rate.
I'm not sure exactly what you're trying to do, but maybe the following
Python session will show you the way.
>>> from Numeric import *
>>> take.__doc__
'take(a, indices, axis=0). Selects the elements in indices from array a along t he given axis.'
>>> a = fromfunction(lambda i,j: 10*i+j, (10,5))
>>> a
array([[ 0, 1, 2, 3, 4],
[10, 11, 12, 13, 14],
[20, 21, 22, 23, 24],
[30, 31, 32, 33, 34],
[40, 41, 42, 43, 44],
[50, 51, 52, 53, 54],
[60, 61, 62, 63, 64],
[70, 71, 72, 73, 74],
[80, 81, 82, 83, 84],
[90, 91, 92, 93, 94]])
>>> b = take(a,(0,2,3,5,7))
>>> b
array([[ 0, 1, 2, 3, 4],
[20, 21, 22, 23, 24],
(Continue reading)
15 Feb 2002 21:03
Re: subsampling
John J. Lee <jjl <at> pobox.com>
2002-02-15 20:03:58 GMT
2002-02-15 20:03:58 GMT
On Thu, 14 Feb 2002, Charles G Waldman wrote: > Mathew Yeates writes: > > > how can I take a matrix and subsample it down to > > an arbitrary size? It seems that using slices is > > limited to constant integer step sizes while, if > > I'm converting between arbitrary sizes, I would like > > to subsample at a nonuniform rate. > > I'm not sure exactly what you're trying to do, but maybe the following > Python session will show you the way. [examples of take() usage snipped] I think -- correct me if I'm wrong -- he was asking about interpolation. If a Python loop is too slow, you can probably do it with the standard numpy functions, with some experimentation. John
15 Feb 2002 21:24
Re: subsampling
Charles G Waldman <cgw <at> alum.mit.edu>
2002-02-15 20:24:30 GMT
2002-02-15 20:24:30 GMT
John J. Lee writes: > I think -- correct me if I'm wrong -- he was asking about interpolation. I think that only Mr Yeates knows for sure! I read the query a few times and I think he's looking for straight-ahead subsampling without interpolation. > If a Python loop is too slow, you can probably do it with the standard > numpy functions, with some experimentation. If interpolation is desired, it might also be worthwhile looking at the Python Imaging Library (PIL), I believe it has routines for resizing images with bilinear interpolation. Since PIL supports many different data formats (even floating point) and it's fairly easy, if inelegant, to inter-convert PIL images and NumPy arrays using "fromstring/tostring" methods (there should be tighter integration between these packages, maybe somebody has done this since last I looked), you might find that the PIL image resizing does what you're looking for.
15 Feb 2002 21:41
Re: subsampling
<mathew <at> fugue.jpl.nasa.gov>
2002-02-15 20:41:21 GMT
2002-02-15 20:41:21 GMT
John J. Lee writes: > I think -- correct me if I'm wrong -- he was asking about interpolation. I think that only Mr Yeates knows for sure! I read the query a few times and I think he's looking for straight-ahead subsampling without interpolation. Yes, I was just asking about subsampling although I did start to think about doing bilinear interpolation. But I was hoping to subsample using built in Numpy functions and .... your solution fits the bill!! Thank you! Mathew
15 Feb 2002 22:17
Interface for numpy C-API <-> simple C++ matrix class
Stefan Heinrichs <Stefan.Heinrichs <at> uni-konstanz.de>
2002-02-15 21:17:00 GMT
2002-02-15 21:17:00 GMT
Hello, we would like to write routines processing numerical python arrays in C++, so that at least boundary checking can be enabled at runtime. While there are a lot of matrix libraries available for C++, I could not find the glue that interfaces such a library to the C-API of numerical python. Seamless access to a minimal C++ library would make the C++ part of programming much easier. Has anyone already written some wrapper/glue code? Thanks and best regards, Stefan -- -- ------------------------------------------------------------------- Email: Stefan.Heinrichs <at> uni-konstanz.de Address: Fakulaet fuer Physik, Universitaet Konstanz, Universitaetsstr.10, 78457 Konstanz, Germany Phone: +49 7531 88 3814
16 Feb 2002 19:00
Converting from FORTRAN Equivalence to a Numpy alternative
Rob <rob <at> pythonemproject.com>
2002-02-16 18:00:05 GMT
2002-02-16 18:00:05 GMT
I hoped there might be a combo FORTRAN/Numpy hacker that might help me
with this. I have the following statements in a FORTRAN routine that I
am converting to Numpy. I am wondering how to handle the EQUIVALENCE
statement. As I understand it, ARL1[1] should be equal to the first
item in the memory block for AR1. But not knowing how FORTRAN allocates
arrays, its hard to tell what to do in Numpy.
I tried ARL1=ravel(AR1) but that didn't work. Similarly ARL=AR[:,1,1}
didn't work. I'm lost.
Thanks in advance for any help. Rob.
#COMMON /GGRID/ AR1(11,10,4),AR2(17,5,4),AR3(9,8,4),EPSCF,DXA(3),&
# &DYA(3),XSA(3),YSA(3),NXA(3),NYA(3
#DIMENSION ARL1(1), ARL2(1), ARL3(1)
#EQUIVALENCE (ARL1,AR1), (ARL2,AR2), (ARL3,AR3), (XS2,XSA(2)),
(YS3,YSA(3))
--
--
The Numeric Python EM Project
www.pythonemproject.com
RSS Feed