Re: Multi-Array comparison [message #71547] |
Mon, 28 June 2010 08:00 |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On Jun 27, 10:57 pm, Jeremy Bailin <astroco...@gmail.com> wrote:
> On Jun 27, 9:40 am, wlandsman <wlands...@gmail.com> wrote:
>
>
>
>
>
>> Here's one way to do what I think you want. (I am not sure what you
>> mean by a "best server".) If your 3 arrays are a,b, and c then
>
>> arrmax = a > b > c ;get the maximum value at each i,j
>> Na = total(a EQ arrmax) ;Number of times the maximum is found in the
>> a array
>> Nb = total(b EQ arrmax)
>> Nc = total(c EQ arrmax)
>
>> Then the maximum of Na, Nb, Nc will tell you which array has the most
>> pixels at the maximum value. (Note that Na + Nb + Nc may be more
>> than the total number of pixels if there are equal values.) --Wayne
>
>> On Jun 27, 4:58 am, Giuseppe Papa <giuseppep...@gmail.com> wrote:
>
>>> Hello everybody,
>
>>> I have three fltarr(460,483) and I would like to compare them, finding
>>> for each element i,j of the arrays which one among the three guarantee
>>> the maximum value. However, since I just need to know a sort of "best
>>> server" index, I'm looking for the percentage so finding the total
>>> amount will be enough. I've found out the WHERE function, but in my
>>> case (three or more arrays) should I make a loop? Any ideas?
>
>>> Thanks,
>
>>> Giuseppe
>
> Or how about:
>
> maxval = max([[[a]],[[b]],[[c]]], dimen=3, ind)
> print, max(histogram(ind / n_elements(a)))
>
> -Jeremy.
Of course, if you already have your storedfiles array set up like
that, susbtitute that for the [[[a]],[[b]],[[c]]] mess. :-)=
I should also point out that, unlike Wayne's code, this one doesn't
attribute equal values to each case where they occur - just to the
first one. So you can construct pathological inputs where it gives the
wrong answer - though if you never or rarely expect to encounter the
same value then you'll never run into it.
-Jeremy.
|
|
|
Re: Multi-Array comparison [message #71555 is a reply to message #71547] |
Sun, 27 June 2010 19:57  |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On Jun 27, 9:40 am, wlandsman <wlands...@gmail.com> wrote:
> Here's one way to do what I think you want. (I am not sure what you
> mean by a "best server".) If your 3 arrays are a,b, and c then
>
> arrmax = a > b > c ;get the maximum value at each i,j
> Na = total(a EQ arrmax) ;Number of times the maximum is found in the
> a array
> Nb = total(b EQ arrmax)
> Nc = total(c EQ arrmax)
>
> Then the maximum of Na, Nb, Nc will tell you which array has the most
> pixels at the maximum value. (Note that Na + Nb + Nc may be more
> than the total number of pixels if there are equal values.) --Wayne
>
> On Jun 27, 4:58 am, Giuseppe Papa <giuseppep...@gmail.com> wrote:
>
>
>
>> Hello everybody,
>
>> I have three fltarr(460,483) and I would like to compare them, finding
>> for each element i,j of the arrays which one among the three guarantee
>> the maximum value. However, since I just need to know a sort of "best
>> server" index, I'm looking for the percentage so finding the total
>> amount will be enough. I've found out the WHERE function, but in my
>> case (three or more arrays) should I make a loop? Any ideas?
>
>> Thanks,
>
>> Giuseppe
Or how about:
maxval = max([[[a]],[[b]],[[c]]], dimen=3, ind)
print, max(histogram(ind / n_elements(a)))
-Jeremy.
|
|
|
Re: Multi-Array comparison [message #71558 is a reply to message #71555] |
Sun, 27 June 2010 07:36  |
Giuseppe Papa
Messages: 27 Registered: February 2010
|
Junior Member |
|
|
On 27 Giu, 15:40, wlandsman <wlands...@gmail.com> wrote:
> Here's one way to do what I think you want. (I am not sure what you
> mean by a "best server".) If your 3 arrays are a,b, and c then
>
> arrmax = a > b > c ;get the maximum value at each i,j
> Na = total(a EQ arrmax) ;Number of times the maximum is found in the
> a array
> Nb = total(b EQ arrmax)
> Nc = total(c EQ arrmax)
>
> Then the maximum of Na, Nb, Nc will tell you which array has the most
> pixels at the maximum value. (Note that Na + Nb + Nc may be more
> than the total number of pixels if there are equal values.) --Wayne
>
> On Jun 27, 4:58 am, Giuseppe Papa <giuseppep...@gmail.com> wrote:
>
>> Hello everybody,
>
>> I have three fltarr(460,483) and I would like to compare them, finding
>> for each element i,j of the arrays which one among the three guarantee
>> the maximum value. However, since I just need to know a sort of "best
>> server" index, I'm looking for the percentage so finding the total
>> amount will be enough. I've found out the WHERE function, but in my
>> case (three or more arrays) should I make a loop? Any ideas?
>
>> Thanks,
>
>> Giuseppe
>
>
Thank you Wayne. First of all, you must forgive me for my bad
English. :-)
I'm talking about "best server" because each array element corresponds
to an electric field value, and I have to evaluate the radio coverage
of an area. Each array belongs to an antenna simulation, so I have to
find which one is "dominant" in each point i,j. I was thinking about
something like this:
for i1=0,nfiles-1 do begin ;nfiles depends on the number of my
simulations, let's say three anyway
apparray=fltarr(nx,ny)+1
for i2=0,nfiles-1 do begin
if (i2 ne i1) then begin
nbestpos=where(storedfiles(*,*,i1) le
storedfiles(*,*,i2))
if max(nbestpos) ne -1 then apparray(nbestpos)=0
endif
endfor
But something doesn't work properly (floating dividing by 0 and this
one "Attempt to subscript MAP2 with I2 is out of range."
|
|
|
Re: Multi-Array comparison [message #71560 is a reply to message #71558] |
Sun, 27 June 2010 06:40  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Here's one way to do what I think you want. (I am not sure what you
mean by a "best server".) If your 3 arrays are a,b, and c then
arrmax = a > b > c ;get the maximum value at each i,j
Na = total(a EQ arrmax) ;Number of times the maximum is found in the
a array
Nb = total(b EQ arrmax)
Nc = total(c EQ arrmax)
Then the maximum of Na, Nb, Nc will tell you which array has the most
pixels at the maximum value. (Note that Na + Nb + Nc may be more
than the total number of pixels if there are equal values.) --Wayne
On Jun 27, 4:58 am, Giuseppe Papa <giuseppep...@gmail.com> wrote:
> Hello everybody,
>
> I have three fltarr(460,483) and I would like to compare them, finding
> for each element i,j of the arrays which one among the three guarantee
> the maximum value. However, since I just need to know a sort of "best
> server" index, I'm looking for the percentage so finding the total
> amount will be enough. I've found out the WHERE function, but in my
> case (three or more arrays) should I make a loop? Any ideas?
>
> Thanks,
>
> Giuseppe
|
|
|