You can subscribe to this list here.
2000 |
Jan
(8) |
Feb
(49) |
Mar
(48) |
Apr
(28) |
May
(37) |
Jun
(28) |
Jul
(16) |
Aug
(16) |
Sep
(44) |
Oct
(61) |
Nov
(31) |
Dec
(24) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(56) |
Feb
(54) |
Mar
(41) |
Apr
(71) |
May
(48) |
Jun
(32) |
Jul
(53) |
Aug
(91) |
Sep
(56) |
Oct
(33) |
Nov
(81) |
Dec
(54) |
2002 |
Jan
(72) |
Feb
(37) |
Mar
(126) |
Apr
(62) |
May
(34) |
Jun
(124) |
Jul
(36) |
Aug
(34) |
Sep
(60) |
Oct
(37) |
Nov
(23) |
Dec
(104) |
2003 |
Jan
(110) |
Feb
(73) |
Mar
(42) |
Apr
(8) |
May
(76) |
Jun
(14) |
Jul
(52) |
Aug
(26) |
Sep
(108) |
Oct
(82) |
Nov
(89) |
Dec
(94) |
2004 |
Jan
(117) |
Feb
(86) |
Mar
(75) |
Apr
(55) |
May
(75) |
Jun
(160) |
Jul
(152) |
Aug
(86) |
Sep
(75) |
Oct
(134) |
Nov
(62) |
Dec
(60) |
2005 |
Jan
(187) |
Feb
(318) |
Mar
(296) |
Apr
(205) |
May
(84) |
Jun
(63) |
Jul
(122) |
Aug
(59) |
Sep
(66) |
Oct
(148) |
Nov
(120) |
Dec
(70) |
2006 |
Jan
(460) |
Feb
(683) |
Mar
(589) |
Apr
(559) |
May
(445) |
Jun
(712) |
Jul
(815) |
Aug
(663) |
Sep
(559) |
Oct
(930) |
Nov
(373) |
Dec
|
From: DrWeb-DAEMON <DrW...@ia...> - 2004-06-04 06:44:05
|
Dear User, The message with following attributes has not been delivered. because contains an infected object. Sender = num...@li... Recipients = ma...@ia... Subject = *****SPAM***** hello Message-ID = <200...@co...> Antivirus filter report: --- Dr.Web report --- ======== infected with Win32.HLLM.Netsky.35328 ======== game_xxo.zip infected with Win32.HLLM.Netsky.35328 ======== known virus is found : 1 --- Dr.Web report --- The original message was stored in archive record named: drweb.infected_wCE8SB In order to receive the original message, please send request to <dr...@ia...>, referring to the archive record name given above. --- Antivirus service provided by Dr.Web(R) Daemon for Unix (http://www.drweb.ru, http://www.dials.ru/english) |
From: Todd M. <jm...@st...> - 2004-06-03 15:06:32
|
On Thu, 2004-06-03 at 04:34, Andrew Wilson wrote: > p.s. -- BOOLEAN_BITWISE_NOT was not defined in > Src/_ufunc_Boolmodule.c, so I just commented it out, recompiled and CVS > worked Thanks for the info. This is fixed now. Todd |
From: Andrew W. <a_w...@mi...> - 2004-06-03 14:34:10
|
Hi Peter, The latest CVS did fix the problem. Thank you very much! Andrew p.s. -- BOOLEAN_BITWISE_NOT was not defined in Src/_ufunc_Boolmodule.c, so I just commented it out, recompiled and CVS worked Peter Verveer wrote: > Hi Andrew, > > If you use the latest release or an older version you may have run > into a bug that displayed that behaviour. I fixed that in the CVS > version, so please try to use that if you are not already doing that. > If you are using the CVS version and still get the problem, please > show me the smallest possible array that displays the problem, and I > will fix it. > > Cheers, Peter > > On Jun 2, 2004, at 2:49 PM, Andrew Wilson wrote: > >> Hello, >> I'm having some trouble with the numarray.nd_image.label() >> function as it is not connecting two objects (that are adjacent) on >> some images. I have tried using the struct: >> [[1,1,1] >> struct = [1,1,1] >> [1,1,1]] >> >> this does change how it is connecting various objects in my image (as >> compared to the default struct) but it still splits the objects >> eventhough they are touching. Any hints or clues? I could send the >> pictures, just don't want to post them to the entire list. > > |
From: Janne S. <jan...@hu...> - 2004-06-03 11:19:08
|
Related to a recent discussion on random numbers: People using RandomArray.random() on 64-bit architectures should also be aware that sometimes the function returns exactly zero or one, which in turn causes problems in many other routines which generate e.g. multinomial or dirichlet variates. I'm not absolutely sure that the problem persists in the newest version of Numeric, and I have not tested it on numarray. Anyway, I have seen it both in Alphas and now later in an AMD Opteron machine - over the years. Unfortunately, as we do not have had time to dig any deeper around here, we have just used wrapper with a test and a loop. -- Janne |
From: Fernando P. <Fer...@co...> - 2004-06-03 00:52:46
|
Hi all, I just tried: root@planck[Numeric-23.1]# ./setup.py build bdist --formats=rpm and after a while I got this traceback: moving build/bdist.linux-i686/rpm/SRPMS/Numeric-23.1-1.src.rpm -> dist Traceback (most recent call last): File "./setup.py", line 182, in ? ext_modules = ext_modules File "/usr/src/build/394694-i386/install/usr/lib/python2.3/distutils/core.py", line 149, in setup File "/usr/src/build/394694-i386/install/usr/lib/python2.3/distutils/dist.py", line 907, in run_commands File "/usr/src/build/394694-i386/install/usr/lib/python2.3/distutils/dist.py", line 927, in run_command File "/usr/src/build/394694-i386/install/usr/lib/python2.3/distutils/command/bdist.py", line 146, in run File "/usr/lib/python2.3/cmd.py", line 333, in run_command File "/usr/src/build/394694-i386/install/usr/lib/python2.3/distutils/dist.py", line 927, in run_command File "/usr/src/build/394694-i386/install/usr/lib/python2.3/distutils/command/bdist_rpm.py", line 316, in run AssertionError: unexpected number of RPM files found: ['build/bdist.linux-i686/rpm/RPMS/i386/Numeric-23.1-1.i386.rpm', 'build/bdist.linux-i686/rpm/RPMS/i386/Numeric-debuginfo-23.1-1.i386.rpm'] As it turns out, the rpm DID get correctly built, but the -debuginfo- one is confusing setup.py. I simply copied the rpm by hand and moved on, but someone who knows more about distutils than me might want to look into this. Cheers, f |
From: Peter V. <ve...@em...> - 2004-06-02 20:37:29
|
Hi Andrew, If you use the latest release or an older version you may have run into a bug that displayed that behaviour. I fixed that in the CVS version, so please try to use that if you are not already doing that. If you are using the CVS version and still get the problem, please show me the smallest possible array that displays the problem, and I will fix it. Cheers, Peter On Jun 2, 2004, at 2:49 PM, Andrew Wilson wrote: > Hello, > I'm having some trouble with the numarray.nd_image.label() function > as it is not connecting two objects (that are adjacent) on some > images. I have tried using the struct: > [[1,1,1] > struct = [1,1,1] > [1,1,1]] > > this does change how it is connecting various objects in my image (as > compared to the default struct) but it still splits the objects > eventhough they are touching. Any hints or clues? I could send the > pictures, just don't want to post them to the entire list. |
From: Russell E O. <rowen@u.washington.edu> - 2004-06-02 19:42:09
|
At 2:49 PM +0200 2004-06-02, Andrew Wilson wrote: >Hello, > I'm having some trouble with the numarray.nd_image.label() >function as it is not connecting two objects (that are adjacent) on >some images. I have tried using the struct: > [[1,1,1] >struct = [1,1,1] > [1,1,1]] > >this does change how it is connecting various objects in my image >(as compared to the default struct) but it still splits the objects >eventhough they are touching. Any hints or clues? I could send the >pictures, just don't want to post them to the entire list. I use it and have not (yet) noticed this, so I hope it's something you're doing and not a bug. You could try generating a boolean version of your image, examine that to make sure the objects are still adjacent on that and use label on it. Here's my code: import numarray as num # smoothed data is a median-filtered version of my image # dataCut is a value above which pixels are considered data shapeArry = num.ones((3,3)) labels, numElts = num.nd_image.label(smoothedData>dataCut, shapeArry) If this doesn't do it (and nobody has anything better to offer), please put the image up somewhere that we can access it and show us your code. -- Russell |
From: Andrew W. <a_w...@mi...> - 2004-06-02 18:48:42
|
Hello, I'm having some trouble with the numarray.nd_image.label() function as it is not connecting two objects (that are adjacent) on some images. I have tried using the struct: [[1,1,1] struct = [1,1,1] [1,1,1]] this does change how it is connecting various objects in my image (as compared to the default struct) but it still splits the objects eventhough they are touching. Any hints or clues? I could send the pictures, just don't want to post them to the entire list. Thanks for your help Andrew |
From: John H. <jdh...@ac...> - 2004-06-02 16:46:41
|
>>>>> "GKarthikesh" == Karthikesh Raju <ka...@ja...> writes: GKarthikesh> Hi All, Thankx to everyone for my previous "Random GKarthikesh> Numbers" question. Ok, do we have the complementary GKarthikesh> error function in numarray? As fas as I know, you'll need to use scipy for that In [3]: import scipy.stats In [4]: scipy.stats.erfc? Type: ufunc String Form: <ufunc 'erfc'> Namespace: Interactive Docstring: y=erfc(x) returns 1 - erf(x). or use pyrex or some other simple wrapper generator to wrap your math library's erfc function... JDH |
From: Karthikesh R. <ka...@ja...> - 2004-06-02 16:37:21
|
Hi All, Thankx to everyone for my previous "Random Numbers" question. Ok, do we have the complementary error function in numarray? i mean erfc(z) = 1 - erf(z) = \frac{2}{\pi} \int_z^\infy e^{t^2}dt (just used LaTeX notation, ran out of ideas to represent it otherwise) Warm regards Karthik ----------------------------------------------------------------------- Karthikesh Raju, email: ka...@ja... Researcher, http://www.cis.hut.fi/karthik Helsinki University of Technology, Tel: +358-9-451 5389 Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 Department of Computer Sc., P.O Box 5400, FIN 02015 HUT, Espoo, FINLAND ----------------------------------------------------------------------- |
From: Karthikesh R. <ka...@ja...> - 2004-06-02 16:29:46
|
Yes, that was something i knew, actually the real problem as Perry, they are a result of overflows due to bools .. With warm regards Karthik ----------------------------------------------------------------------- Karthikesh Raju, email: ka...@ja... Researcher, http://www.cis.hut.fi/karthik Helsinki University of Technology, Tel: +358-9-451 5389 Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 Department of Computer Sc., P.O Box 5400, FIN 02015 HUT, Espoo, FINLAND ----------------------------------------------------------------------- On Wed, 2 Jun 2004, John Hunter wrote: > >>>>> "Karthikesh" == Karthikesh Raju <ka...@ja...> writes: > > Karthikesh> Thankx Perry, now i an getting somewhere near, but > Karthikesh> there are still some issues, matlab and python (exact > Karthikesh> algorithms) result in different values :(, looking at > Karthikesh> it though, > > One obvious difference, which you are likely aware of, is that rand(N) > in matlab returns an NxN matrix whereas Numeric's MLab and numarray's > linear_algebra.mlab version of rand returns a length N array. So if > you naively use rand(N) in both cases, your sample sizes will be > wildly different. > > Just a thought... > > JDH > > |
From: John H. <jdh...@ac...> - 2004-06-02 16:27:35
|
>>>>> "Karthikesh" == Karthikesh Raju <ka...@ja...> writes: Karthikesh> Thankx Perry, now i an getting somewhere near, but Karthikesh> there are still some issues, matlab and python (exact Karthikesh> algorithms) result in different values :(, looking at Karthikesh> it though, One obvious difference, which you are likely aware of, is that rand(N) in matlab returns an NxN matrix whereas Numeric's MLab and numarray's linear_algebra.mlab version of rand returns a length N array. So if you naively use rand(N) in both cases, your sample sizes will be wildly different. Just a thought... JDH |
From: Karthikesh R. <ka...@ja...> - 2004-06-02 16:10:21
|
Thankx Perry, now i an getting somewhere near, but there are still some issues, matlab and python (exact algorithms) result in different values :(, looking at it though, Warm regards karthik ----------------------------------------------------------------------- Karthikesh Raju, email: ka...@ja... Researcher, http://www.cis.hut.fi/karthik Helsinki University of Technology, Tel: +358-9-451 5389 Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 Department of Computer Sc., P.O Box 5400, FIN 02015 HUT, Espoo, FINLAND ----------------------------------------------------------------------- On Wed, 2 Jun 2004, Perry Greenfield wrote: > > I'm guessing you are seeing overflow problems with the boolean > > representation which is the result of logical comparisons > > (which uses only 8 bit values) try: > > > > sum(float(not_equal... > > > > to eliminate that problem. > > > > Perry > > > arg, I should have said: > > sum(not_equal(...).astype(Float)) > > |
From: Perry G. <pe...@st...> - 2004-06-02 15:42:10
|
> I'm guessing you are seeing overflow problems with the boolean > representation which is the result of logical comparisons > (which uses only 8 bit values) try: > > sum(float(not_equal... > > to eliminate that problem. > > Perry > arg, I should have said: sum(not_equal(...).astype(Float)) |
From: Karthikesh R. <ka...@ja...> - 2004-06-02 15:41:05
|
Hi Perry and All, Thankx a lot for your reply. i actually forgot to mention it, but a = rand(100000) > 0.5 b = rand(100000) > 0.5 sum(float(a,b)) results in a TypeError: Only rank-0 numarray can be cast to floats. With warm regards karthik ----------------------------------------------------------------------- Karthikesh Raju, email: ka...@ja... Researcher, http://www.cis.hut.fi/karthik Helsinki University of Technology, Tel: +358-9-451 5389 Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 Department of Computer Sc., P.O Box 5400, FIN 02015 HUT, Espoo, FINLAND ----------------------------------------------------------------------- On Wed, 2 Jun 2004, Perry Greenfield wrote: > Karthikesh Raju wrote: > > > > n_Errors = sum(not_equal(Tx_Bit_Stream,Rx_Bit_Stream)) > > > > Now i have noted that n_Errors is negative? How can that be so? > > > > n_Errors should be the number of places where Tx_Bit_Stream differs from > > Rx_Bit_Stream? How can the sum be negative? > > > > > I'm guessing you are seeing overflow problems with the boolean > representation which is the result of logical comparisons > (which uses only 8 bit values) try: > > sum(float(not_equal... > > to eliminate that problem. > > Perry > > |
From: Perry G. <pe...@st...> - 2004-06-02 15:34:38
|
Karthikesh Raju wrote: > > n_Errors = sum(not_equal(Tx_Bit_Stream,Rx_Bit_Stream)) > > Now i have noted that n_Errors is negative? How can that be so? > > n_Errors should be the number of places where Tx_Bit_Stream differs from > Rx_Bit_Stream? How can the sum be negative? > > I'm guessing you are seeing overflow problems with the boolean representation which is the result of logical comparisons (which uses only 8 bit values) try: sum(float(not_equal... to eliminate that problem. Perry |
From: Karthikesh R. <ka...@ja...> - 2004-06-02 15:28:34
|
Hi Bruce and All, Probably i jumped the wagon and thought the problem was with randn. Think i have isolated the problem: say: a = rand(10000) > 0.5 b = rand(10000) > 0.5 now to compare and find the number of differences or errors: sum(a!=b) or sum(not_equal(a,b)) How can this value be negative at times? With warm regards karthik ----------------------------------------------------------------------- Karthikesh Raju, email: ka...@ja... Researcher, http://www.cis.hut.fi/karthik Helsinki University of Technology, Tel: +358-9-451 5389 Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 Department of Computer Sc., P.O Box 5400, FIN 02015 HUT, Espoo, FINLAND ----------------------------------------------------------------------- On Wed, 2 Jun 2004, Bruce Southey wrote: > Hi, > All three use different but well-known algorithms > > For Matlab 5 onwards, this references the randn (which is the standard normal): > http://www.mathworks.com/company/newsletters/news_notes/clevescorner/spring01_cleve.html > > (You also note the link to Matlabs uniform generator that has excellent > properties.) > > numarray.random_array.normal that uses ranlib snorm (snorm is the standard normal). > > numarray.linear_algebra.mlab.randn uses the Box-Muller method using random > uniform numbers from ranlib. > > Your problems suggest that randn is not the cause. Without any code or what you > want to do it hard to address your question except that you should ensure that > your sampling does provide the normal distribution with your parameters. By that > I mean draw many, many samples from one set of parameters and check the > estimated mean and variance. > > Regards > Bruce > > ---- Original message ---- > >Date: Wed, 2 Jun 2004 17:27:02 +0300 > >From: Karthikesh Raju <ka...@ja...> > >Subject: [Numpy-discussion] Random Numbers > >To: num...@li... > > > >Hi All, > > > >How close is the random number generation from > >numarray.random_array.normal(0,1,x) or > >numarray.linear_algebra.mlab.randn(x) to matlab's randn? > > > >i am having problems with an identical program written in matlab and > >python, with the results entirely different in both cases :( > > > >Warm regards > > > >karthik > > > > > >----------------------------------------------------------------------- > >Karthikesh Raju, email: ka...@ja... > >Researcher, http://www.cis.hut.fi/karthik > >Helsinki University of Technology, Tel: +358-9-451 5389 > >Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 > >Department of Computer Sc., > >P.O Box 5400, FIN 02015 HUT, > >Espoo, FINLAND > >----------------------------------------------------------------------- > > > > > >------------------------------------------------------- > >This SF.Net email is sponsored by the new InstallShield X. > >From Windows to Linux, servers to mobile, InstallShield X is the one > >installation-authoring solution that does it all. Learn more and > >evaluate today! http://www.installshield.com/Dev2Dev/0504 > >_______________________________________________ > >Numpy-discussion mailing list > >Num...@li... > >https://lists.sourceforge.net/lists/listinfo/numpy-discussion > > |
From: Bruce S. <so...@ui...> - 2004-06-02 15:17:19
|
Hi, All three use different but well-known algorithms For Matlab 5 onwards, this references the randn (which is the standard normal): http://www.mathworks.com/company/newsletters/news_notes/clevescorner/spring01_cleve.html (You also note the link to Matlabs uniform generator that has excellent properties.) numarray.random_array.normal that uses ranlib snorm (snorm is the standard normal). numarray.linear_algebra.mlab.randn uses the Box-Muller method using random uniform numbers from ranlib. Your problems suggest that randn is not the cause. Without any code or what you want to do it hard to address your question except that you should ensure that your sampling does provide the normal distribution with your parameters. By that I mean draw many, many samples from one set of parameters and check the estimated mean and variance. Regards Bruce ---- Original message ---- >Date: Wed, 2 Jun 2004 17:27:02 +0300 >From: Karthikesh Raju <ka...@ja...> >Subject: [Numpy-discussion] Random Numbers >To: num...@li... > >Hi All, > >How close is the random number generation from >numarray.random_array.normal(0,1,x) or >numarray.linear_algebra.mlab.randn(x) to matlab's randn? > >i am having problems with an identical program written in matlab and >python, with the results entirely different in both cases :( > >Warm regards > >karthik > > >----------------------------------------------------------------------- >Karthikesh Raju, email: ka...@ja... >Researcher, http://www.cis.hut.fi/karthik >Helsinki University of Technology, Tel: +358-9-451 5389 >Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 >Department of Computer Sc., >P.O Box 5400, FIN 02015 HUT, >Espoo, FINLAND >----------------------------------------------------------------------- > > >------------------------------------------------------- >This SF.Net email is sponsored by the new InstallShield X. >From Windows to Linux, servers to mobile, InstallShield X is the one >installation-authoring solution that does it all. Learn more and >evaluate today! http://www.installshield.com/Dev2Dev/0504 >_______________________________________________ >Numpy-discussion mailing list >Num...@li... >https://lists.sourceforge.net/lists/listinfo/numpy-discussion |
From: Karthikesh R. <ka...@ja...> - 2004-06-02 15:04:40
|
Hi Perry, Yes, i have been trying to compare random number generators. i plotted the histograms, they look quite "gaussian", i have also tried uniform numbers with "rand". May be there is some problem with one of my statements like: def AWGN(Tx_Symbols,No): len_Waveform = len(Tx_Waveform) std_No = sqrt(No/2.0) return Tx_Waveform + std_No*randn(len_Waveform) This function just takes in a bit stream in [1,-1] and adds gaussian noise. No defines the noise power. Now in the main function i am doing: Tx_Bit_Stream = random(n_Bits) > 0.5 Tx_Symbols = 2*Tx_Bit_Stream-1 Rx_Symbols = AWGN(Tx_Symbols, No) Rx_Bit_Stream = Rx_Symbols > 0 n_Errors = sum(not_equal(Tx_Bit_Stream,Rx_Bit_Stream)) Now i have noted that n_Errors is negative? How can that be so? n_Errors should be the number of places where Tx_Bit_Stream differs from Rx_Bit_Stream? How can the sum be negative? With warm regards karthik ----------------------------------------------------------------------- Karthikesh Raju, email: ka...@ja... Researcher, http://www.cis.hut.fi/karthik Helsinki University of Technology, Tel: +358-9-451 5389 Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 Department of Computer Sc., P.O Box 5400, FIN 02015 HUT, Espoo, FINLAND ----------------------------------------------------------------------- On Wed, 2 Jun 2004, Perry Greenfield wrote: > Karthikesh Raju wrote: > > > How close is the random number generation from > > numarray.random_array.normal(0,1,x) or > > numarray.linear_algebra.mlab.randn(x) to matlab's randn? > > > > i am having problems with an identical program written in matlab and > > python, with the results entirely different in both cases :( > > > Unfortunately, I'm not familiar with matlab and don't have it here > to run. Have you tried comparing simple things between the two > such as mean and standard deviation to see if you are getting > the same result, followed by histograms if you see no differences > there? > > Perry Greenfield > > |
From: Perry G. <pe...@st...> - 2004-06-02 14:45:56
|
Karthikesh Raju wrote: > How close is the random number generation from > numarray.random_array.normal(0,1,x) or > numarray.linear_algebra.mlab.randn(x) to matlab's randn? > > i am having problems with an identical program written in matlab and > python, with the results entirely different in both cases :( > Unfortunately, I'm not familiar with matlab and don't have it here to run. Have you tried comparing simple things between the two such as mean and standard deviation to see if you are getting the same result, followed by histograms if you see no differences there? Perry Greenfield |
From: Karthikesh R. <ka...@ja...> - 2004-06-02 14:27:52
|
Hi All, How close is the random number generation from numarray.random_array.normal(0,1,x) or numarray.linear_algebra.mlab.randn(x) to matlab's randn? i am having problems with an identical program written in matlab and python, with the results entirely different in both cases :( Warm regards karthik ----------------------------------------------------------------------- Karthikesh Raju, email: ka...@ja... Researcher, http://www.cis.hut.fi/karthik Helsinki University of Technology, Tel: +358-9-451 5389 Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277 Department of Computer Sc., P.O Box 5400, FIN 02015 HUT, Espoo, FINLAND ----------------------------------------------------------------------- |
From: Nadav H. <na...@vi...> - 2004-06-02 10:15:47
|
-----Original Message----- From: Perry Greenfield [mailto:pe...@st...] Sent: Tue 01-Jun-04 19:16 To: Nadav Horesh; numpy-discussion Cc:=09 Subject: RE: [Numpy-discussion] searchsorted Nadav Horesh writes > I am currently working on a simulation that makes a heavy use of=20 > searchsorted. But it does not precisely fit to what I need --- if a=20 > value v is between p and q searchsorted returns the index of q, while = > what I need is the index of p. >=20 > Currently my solution is to turn to floating points numbers: >=20 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > Python 2.3.4 (#1, May 31 2004, 09:13:03) > [GCC 3.4.0] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > from numarray import * >=20 > bins =3D array((0,10,20,30)) > val =3D array((10, 15)) > searchsorted(bins, val) > array([1, 2]) # I really would like to get array([1, 1]) >=20 > # Here is the trick: >=20 > fb =3D bins - 0.1 > fb > array([ -0.1, 9.9, 19.9, 29.9]) >=20 > searchsorted(fb, val) - 1 > array([1, 1]) # That's it! >=20 This is only approximate, right? If val =3D array([9.95, 15]) you will get the wrong answer won't you? > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > My questions are: >=20 > 1. Is there a more elegant solution? > 2. I am thinking of letting "searchsorted" return a second boolean > array which has the value True for every exact match: > >>> searchsorted(bins, val) > >>> [array([1, 2]), array([1, 0], type=3DBool)] > Any comments? >=20 > Nadav. >=20 To get the latter, you could so something like ind =3D searchsorted(bins, val) neq_mask =3D bins[ind]-val ind[neq_mask] -=3D 1. # well, you need to handle where ind =3D 0 and # is not equal as well Would that suffice? Perry ------------------------------------- Got the idea, the line should be really: ind =3D ind - (bins[ind] !=3D val) You helped a lot. Thank you very much, Nadav. |
From: Perry G. <pe...@st...> - 2004-06-01 16:16:12
|
Nadav Horesh writes > I am currently working on a simulation that makes a heavy use of > searchsorted. But it does not precisely fit to what I need --- if a > value v is between p and q searchsorted returns the index of q, while > what I need is the index of p. > > Currently my solution is to turn to floating points numbers: > > ====================================== > > Python 2.3.4 (#1, May 31 2004, 09:13:03) > [GCC 3.4.0] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > from numarray import * > > bins = array((0,10,20,30)) > val = array((10, 15)) > searchsorted(bins, val) > array([1, 2]) # I really would like to get array([1, 1]) > > # Here is the trick: > > fb = bins - 0.1 > fb > array([ -0.1, 9.9, 19.9, 29.9]) > > searchsorted(fb, val) - 1 > array([1, 1]) # That's it! > This is only approximate, right? If val = array([9.95, 15]) you will get the wrong answer won't you? > ============================================ > > My questions are: > > 1. Is there a more elegant solution? > 2. I am thinking of letting "searchsorted" return a second boolean > array which has the value True for every exact match: > >>> searchsorted(bins, val) > >>> [array([1, 2]), array([1, 0], type=Bool)] > Any comments? > > Nadav. > To get the latter, you could so something like ind = searchsorted(bins, val) neq_mask = bins[ind]-val ind[neq_mask] -= 1. # well, you need to handle where ind = 0 and # is not equal as well Would that suffice? Perry |
From: Nadav H. <na...@vi...> - 2004-06-01 13:31:54
|
I am currently working on a simulation that makes a heavy use of searchsorted. But it does not precisely fit to what I need --- if a value v is between p and q searchsorted returns the index of q, while what I need is the index of p. Currently my solution is to turn to floating points numbers: ====================================== Python 2.3.4 (#1, May 31 2004, 09:13:03) [GCC 3.4.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. from numarray import * bins = array((0,10,20,30)) val = array((10, 15)) searchsorted(bins, val) array([1, 2]) # I really would like to get array([1, 1]) # Here is the trick: fb = bins - 0.1 fb array([ -0.1, 9.9, 19.9, 29.9]) searchsorted(fb, val) - 1 array([1, 1]) # That's it! ============================================ My questions are: 1. Is there a more elegant solution? 2. I am thinking of letting "searchsorted" return a second boolean array which has the value True for every exact match: >>> searchsorted(bins, val) >>> [array([1, 2]), array([1, 0], type=Bool)] Any comments? Nadav. |
From: Cheryle R. <kck...@in...> - 2004-06-01 06:17:07
|
mountain season laughed perfect done justice now tie maybe excite my loose experience listen conscience across likely slipped step ache thought |