I have an integer array with values limited to range(a,b) like:
ia=array([1,2,3,3,3,4,...2,0,1])
and want to speedly count the frequencies of the integers into get a density matrix.
Is this possible without looping?
Question 2: is it possible to compute a "moving maximum" without python looping
ia=array([4,2,1,5,3,2,2,0,1,1])
-mvmax(ia,3) ->
[4,4,4,5,5,5,3,2,2,1])
Robert 2 2205
robert wrote:
I have an integer array with values limited to range(a,b) like:
ia=array([1,2,3,3,3,4,...2,0,1])
and want to speedly count the frequencies of the integers into get a density matrix.
Is this possible without looping?
See numpy.bincount (for integers >= 0) if you mean 'without writing
looping code in Python' or please specify your question.
Question 2: is it possible to compute a "moving maximum" without python looping
ia=array([4,2,1,5,3,2,2,0,1,1])
-mvmax(ia,3) ->
[4,4,4,5,5,5,3,2,2,1])
I haven't seen a ready solution but this can be easily converted into
Pyrex/C looping.
cheers,
fw
Filip Wasilewski wrote:
robert wrote:
>I have an integer array with values limited to range(a,b) like:
ia=array([1,2,3,3,3,4,...2,0,1])
and want to speedly count the frequencies of the integers into get a density matrix. Is this possible without looping?
See numpy.bincount (for integers >= 0) if you mean 'without writing
looping code in Python' or please specify your question.
>Question 2: is it possible to compute a "moving maximum" without python looping
ia=array([4,2,1,5,3,2,2,0,1,1]) -mvmax(ia,3) -> [4,4,4,5,5,5,3,2,2,1])
I haven't seen a ready solution but this can be easily converted into
Pyrex/C looping.
I don't know a way to avoid looping entirely, but there are ways that
you can loop over the width of the window (in this case 3) rather than
over the entire array. Since the window width is generally small
compared to the array, this will probably be fast enough. The tricky
part is to get the value right at the edges, since what you do there
depends on what boundary conditions you apply.
The general idea is this:
result = ia[n-1:]
for i in range(n-1):
numpy.maximum(result, ia[i:-n+i], result)
This punts on dealing with the ends (and I haven't tested this version),
but should give you the idea.
-tim This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Giovanni Ciampaglia |
last post by:
Hello everyone,
Could someone explain me what is the "steady-state" value contained into the
array returned by FFT.fft(data,n=None,axis=-1) at its first position?
Is it one of the values...
|
by: Gary Wessle |
last post by:
Hi
I am trying to install NumPy in my debian/testing linux
2.6.15-1-686.
with no numpy for debian/testing, I am left alone, since the
experimental version available by debian will result in a...
|
by: Iljya |
last post by:
Hello,
I need to pickle the type numpy.float32 but encounter an error when I
try to do so. I am able to pickle the array itself, it is specifically
the type that I cannot pickle.
I am using:...
|
by: robert |
last post by:
just a note - some speed comparisons :
0.60627370238398726
0.42836673376223189
0.36965815487747022
0.016557970357098384
0.15692469294117473
0.01951756438393204
|
by: robert |
last post by:
in Gnuplot (Gnuplot.utils) the input array will be converted to a Numeric float array as shown below. When I insert a numpy array into Gnuplot like that below, numbers 7.44 are cast to 7.0
Why is...
|
by: Chris Smith |
last post by:
Howdy,
I'm a college student and for one of we are writing programs to
numerically compute the parameters of antenna arrays. I decided to use
Python to code up my programs. Up to now I haven't...
|
by: robert |
last post by:
Turning algs for old NumPy modules into numpy code I suffer from this:
Upon further processing of returns of numpy calculations, lots of data in an apps object tree will become elementary numpy...
|
by: rajash |
last post by:
Hello everyone,
Thanks again for all the suggestions, though I think some people are a
bit fussy in their answers.
Here is a solution to Exercise 1.14. It deals well with control
characters...
|
by: Travis Oliphant |
last post by:
I wanted to point anybody interested to a blog post that describes a
useful pattern for having a NumPy array that points to the memory
created by a different memory manager than the standard one...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |