comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: I think we need more information. The range that the elements can take would be useful. If, for instance they are integers between 0 and 10 you could use the where command in conjunction with the count option to check how many times a given value occurs. Hope this helps. Russell.
creator: russell.grew
date: 2008-07-29T00:43:25-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: We do need some more information but this is just screaming for histogram. Have a read through http://www.dfanning.com/tips/histogram_tutorial.html . Using histogram to see which x's are common you can step through the reverse_indices and see which y's are then common. There is probably a more graceful way however. Cheers, Brian ------------------------------------------------------------ -------------- Brian Larsen Boston University Center for Space Physics http://people.bu.edu/balarsen/Home/IDL
creator: Brian Larsen
date: 2008-07-29T06:32:21-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > We do need some more information but this is just screaming for > histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html > . Using histogram to see which x's are common you can step through > the reverse_indices and see which y's are then common. There is > probably a more graceful way however. > > Cheers, > > Brian > > ------------------------------------------------------------ -------------- > Brian Larsen > Boston University > Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL In particular, if you're dealing with integers that don't span too big a range, use HIST_2D and find the maximum element. If you've got floats or a wide range, use UNIQ to turn each into an integer on a small range first. -Jeremy.
creator: Jeremy Bailin
date: 2008-07-29T15:50:02-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Jul 29, 11:50 am, Jeremy Bailin <astroco...@gmail.com> wrote: > On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > >> We do need some more information but this is just screaming for >> histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html >> . Using histogram to see which x's are common you can step through >> the reverse_indices and see which y's are then common. There is >> probably a more graceful way however. > >> Cheers, > >> Brian > >> ------------------------------------------------------------ -------------- >> Brian Larsen >> Boston University >> Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL > > In particular, if you're dealing with integers that don't span too big > a range, use HIST_2D and find the maximum element. If you've got > floats or a wide range, use UNIQ to turn each into an integer on a > small range first. > > -Jeremy. I think if I were to be working with small datasets....ie not in the millions of points I would use something like this coords = [[10,1],[20,32],[5,7],[6,8],[20,32],[2,14],[20,32],[10,10], [3,1],[21,14]] counter = intarr(9) FOR i = 0, 8 DO BEGIN FOR j = 0, 8 DO BEGIN IF array_equal(coords[*,i],coords[*,j]) THEN counter[i]++ ENDFOR ENDFOR ;- Histogram to find the max bins (no need to measure anything below 2 ;- because that would just be a single hit and if all of your pairs ;- only occur once then who cares, right? hist = histogram(counter, min=2, reverse_indices=ri) maxHist = max(hist, mxpos) IF maxHist EQ 1 THEN print, 'Each pair occurs no more than once' ;- Use the reverse indices given by histogram to find out exactly ;- where in your counter these maxes are occurring array_index = (counter[ri[ri[1]:ri[2]-1]])[0] ;- Find where counter is equal to the array index determined by ;- reverse indices max_index = where(counter EQ array_index) ;- Voila with your max pair print, coords[*,max_index[0]] Which spits out.... 20 32 This could be tweaked to find the top two or thr…
creator: Juggernaut
date: 2008-07-30T11:54:00-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Jul 30, 7:54 am, Bennett <juggernau...@gmail.com> wrote: > On Jul 29, 11:50 am, Jeremy Bailin <astroco...@gmail.com> wrote: > > > >> On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > >>> We do need some more information but this is just screaming for >>> histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html >>> . Using histogram to see which x's are common you can step through >>> the reverse_indices and see which y's are then common. There is >>> probably a more graceful way however. > >>> Cheers, > >>> Brian > >>> ------------------------------------------------------------ -------------- >>> Brian Larsen >>> Boston University >>> Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL > >> In particular, if you're dealing with integers that don't span too big >> a range, use HIST_2D and find the maximum element. If you've got >> floats or a wide range, use UNIQ to turn each into an integer on a >> small range first. > >> -Jeremy. > > I think if I were to be working with small datasets....ie not in the > millions of points I would use something like this > > coords = [[10,1],[20,32],[5,7],[6,8],[20,32],[2,14],[20,32],[10,10], > [3,1],[21,14]] > > counter = intarr(9) > > FOR i = 0, 8 DO BEGIN > FOR j = 0, 8 DO BEGIN > > IF array_equal(coords[*,i],coords[*,j]) THEN counter[i]++ > > ENDFOR > ENDFOR > > ;- Histogram to find the max bins (no need to measure anything below 2 > ;- because that would just be a single hit and if all of your pairs > ;- only occur once then who cares, right? > hist = histogram(counter, min=2, reverse_indices=ri) > maxHist = max(hist, mxpos) > IF maxHist EQ 1 THEN print, 'Each pair occurs no more than once' > > ;- Use the reverse indices given by histogram to find out exactly > ;- where in your counter these maxes are occurring > array_index = (counter[ri[ri[1]:ri[2]-1]])[0] > > ;- Find where counter is equal to the array index determined by > ;- reverse indices > max_index = where(counter E…
creator: Juggernaut
date: 2008-07-30T12:35:43-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Jul 30, 7:54 am, Bennett <juggernau...@gmail.com> wrote: > On Jul 29, 11:50 am, Jeremy Bailin <astroco...@gmail.com> wrote: > > > >> On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > >>> We do need some more information but this is just screaming for >>> histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html >>> . Using histogram to see which x's are common you can step through >>> the reverse_indices and see which y's are then common. There is >>> probably a more graceful way however. > >>> Cheers, > >>> Brian > >>> ------------------------------------------------------------ -------------- >>> Brian Larsen >>> Boston University >>> Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL > >> In particular, if you're dealing with integers that don't span too big >> a range, use HIST_2D and find the maximum element. If you've got >> floats or a wide range, use UNIQ to turn each into an integer on a >> small range first. > >> -Jeremy. > > I think if I were to be working with small datasets....ie not in the > millions of points I would use something like this > > coords = [[10,1],[20,32],[5,7],[6,8],[20,32],[2,14],[20,32],[10,10], > [3,1],[21,14]] > > counter = intarr(9) > > FOR i = 0, 8 DO BEGIN > FOR j = 0, 8 DO BEGIN > > IF array_equal(coords[*,i],coords[*,j]) THEN counter[i]++ > > ENDFOR > ENDFOR > > ;- Histogram to find the max bins (no need to measure anything below 2 > ;- because that would just be a single hit and if all of your pairs > ;- only occur once then who cares, right? > hist = histogram(counter, min=2, reverse_indices=ri) > maxHist = max(hist, mxpos) > IF maxHist EQ 1 THEN print, 'Each pair occurs no more than once' > > ;- Use the reverse indices given by histogram to find out exactly > ;- where in your counter these maxes are occurring > array_index = (counter[ri[ri[1]:ri[2]-1]])[0] > > ;- Find where counter is equal to the array index determined by > ;- reverse indices > max_index = where(counter E…
creator: Jeremy Bailin
date: 2008-07-31T11:37:16-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Jul 31, 7:37 am, Jeremy Bailin <astroco...@gmail.com> wrote: > On Jul 30, 7:54 am, Bennett <juggernau...@gmail.com> wrote: > > > >> On Jul 29, 11:50 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>> On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > >>>> We do need some more information but this is just screaming for >>>> histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html >>>> . Using histogram to see which x's are common you can step through >>>> the reverse_indices and see which y's are then common. There is >>>> probably a more graceful way however. > >>>> Cheers, > >>>> Brian > >>>> ------------------------------------------------------------ -------------- >>>> Brian Larsen >>>> Boston University >>>> Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL > >>> In particular, if you're dealing with integers that don't span too big >>> a range, use HIST_2D and find the maximum element. If you've got >>> floats or a wide range, use UNIQ to turn each into an integer on a >>> small range first. > >>> -Jeremy. > >> I think if I were to be working with small datasets....ie not in the >> millions of points I would use something like this > >> coords = [[10,1],[20,32],[5,7],[6,8],[20,32],[2,14],[20,32],[10,10], >> [3,1],[21,14]] > >> counter = intarr(9) > >> FOR i = 0, 8 DO BEGIN >> FOR j = 0, 8 DO BEGIN > >> IF array_equal(coords[*,i],coords[*,j]) THEN counter[i]++ > >> ENDFOR >> ENDFOR > >> ;- Histogram to find the max bins (no need to measure anything below 2 >> ;- because that would just be a single hit and if all of your pairs >> ;- only occur once then who cares, right? >> hist = histogram(counter, min=2, reverse_indices=ri) >> maxHist = max(hist, mxpos) >> IF maxHist EQ 1 THEN print, 'Each pair occurs no more than once' > >> ;- Use the reverse indices given by histogram to find out exactly >> ;- where in your counter these maxes are occurring >> array_index = (counter[ri[ri[1]:ri[2]-1]])[0] > >> ;- Find …
creator: Juggernaut
date: 2008-07-31T14:50:05-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Jul 31, 10:50 am, Bennett <juggernau...@gmail.com> wrote: > On Jul 31, 7:37 am, Jeremy Bailin <astroco...@gmail.com> wrote: > > > >> On Jul 30, 7:54 am, Bennett <juggernau...@gmail.com> wrote: > >>> On Jul 29, 11:50 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>>> On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > >>>> > We do need some more information but this is just screaming for >>>> > histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html >>>> > . Using histogram to see which x's are common you can step through >>>> > the reverse_indices and see which y's are then common. There is >>>> > probably a more graceful way however. > >>>> > Cheers, > >>>> > Brian > >>>> > ------------------------------------------------------------ -------------- >>>> > Brian Larsen >>>> > Boston University >>>> > Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL > >>>> In particular, if you're dealing with integers that don't span too big >>>> a range, use HIST_2D and find the maximum element. If you've got >>>> floats or a wide range, use UNIQ to turn each into an integer on a >>>> small range first. > >>>> -Jeremy. > >>> I think if I were to be working with small datasets....ie not in the >>> millions of points I would use something like this > >>> coords = [[10,1],[20,32],[5,7],[6,8],[20,32],[2,14],[20,32],[10,10], >>> [3,1],[21,14]] > >>> counter = intarr(9) > >>> FOR i = 0, 8 DO BEGIN >>> FOR j = 0, 8 DO BEGIN > >>> IF array_equal(coords[*,i],coords[*,j]) THEN counter[i]++ > >>> ENDFOR >>> ENDFOR > >>> ;- Histogram to find the max bins (no need to measure anything below 2 >>> ;- because that would just be a single hit and if all of your pairs >>> ;- only occur once then who cares, right? >>> hist = histogram(counter, min=2, reverse_indices=ri) >>> maxHist = max(hist, mxpos) >>> IF maxHist EQ 1 THEN print, 'Each pair occurs no more than once' > >>> ;- Use the reverse indices given by histogram to find out exactly >>> …
creator: Jeremy Bailin
date: 2008-08-01T11:02:09-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Aug 1, 7:02 am, Jeremy Bailin <astroco...@gmail.com> wrote: > On Jul 31, 10:50 am, Bennett <juggernau...@gmail.com> wrote: > > > >> On Jul 31, 7:37 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>> On Jul 30, 7:54 am, Bennett <juggernau...@gmail.com> wrote: > >>>> On Jul 29, 11:50 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>>> > On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > >>>> > > We do need some more information but this is just screaming for >>>> > > histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html >>>> > > . Using histogram to see which x's are common you can step through >>>> > > the reverse_indices and see which y's are then common. There is >>>> > > probably a more graceful way however. > >>>> > > Cheers, > >>>> > > Brian > >>>> > > ------------------------------------------------------------ -------------- >>>> > > Brian Larsen >>>> > > Boston University >>>> > > Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL > >>>> > In particular, if you're dealing with integers that don't span too big >>>> > a range, use HIST_2D and find the maximum element. If you've got >>>> > floats or a wide range, use UNIQ to turn each into an integer on a >>>> > small range first. > >>>> > -Jeremy. > >>>> I think if I were to be working with small datasets....ie not in the >>>> millions of points I would use something like this > >>>> coords = [[10,1],[20,32],[5,7],[6,8],[20,32],[2,14],[20,32],[10,10], >>>> [3,1],[21,14]] > >>>> counter = intarr(9) > >>>> FOR i = 0, 8 DO BEGIN >>>> FOR j = 0, 8 DO BEGIN > >>>> IF array_equal(coords[*,i],coords[*,j]) THEN counter[i]++ > >>>> ENDFOR >>>> ENDFOR > >>>> ;- Histogram to find the max bins (no need to measure anything below 2 >>>> ;- because that would just be a single hit and if all of your pairs >>>> ;- only occur once then who cares, right? >>>> hist = histogram(counter, min=2, reverse_indices=ri) >>>> maxHist = max(hist, mxpos) >>>> IF maxHist EQ 1 THEN …
creator: Juggernaut
date: 2008-08-05T14:14:23-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Aug 5, 10:14 am, Bennett <juggernau...@gmail.com> wrote: > On Aug 1, 7:02 am, Jeremy Bailin <astroco...@gmail.com> wrote: > > > >> On Jul 31, 10:50 am, Bennett <juggernau...@gmail.com> wrote: > >>> On Jul 31, 7:37 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>>> On Jul 30, 7:54 am, Bennett <juggernau...@gmail.com> wrote: > >>>> > On Jul 29, 11:50 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>>> > > On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > >>>> > > > We do need some more information but this is just screaming for >>>> > > > histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html >>>> > > > . Using histogram to see which x's are common you can step through >>>> > > > the reverse_indices and see which y's are then common. There is >>>> > > > probably a more graceful way however. > >>>> > > > Cheers, > >>>> > > > Brian > >>>> > > > ------------------------------------------------------------ -------------- >>>> > > > Brian Larsen >>>> > > > Boston University >>>> > > > Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL > >>>> > > In particular, if you're dealing with integers that don't span too big >>>> > > a range, use HIST_2D and find the maximum element. If you've got >>>> > > floats or a wide range, use UNIQ to turn each into an integer on a >>>> > > small range first. > >>>> > > -Jeremy. > >>>> > I think if I were to be working with small datasets....ie not in the >>>> > millions of points I would use something like this > >>>> > coords = [[10,1],[20,32],[5,7],[6,8],[20,32],[2,14],[20,32],[10,10], >>>> > [3,1],[21,14]] > >>>> > counter = intarr(9) > >>>> > FOR i = 0, 8 DO BEGIN >>>> > FOR j = 0, 8 DO BEGIN > >>>> > IF array_equal(coords[*,i],coords[*,j]) THEN counter[i]++ > >>>> > ENDFOR >>>> > ENDFOR > >>>> > ;- Histogram to find the max bins (no need to measure anything below 2 >>>> > ;- because that would just be a single hit and if all of your pairs >>>> > ;- only occur once then who c…
creator: Jeremy Bailin
date: 2008-08-06T11:28:00-00:00

Re: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
type: item
description: On Aug 6, 7:28 am, Jeremy Bailin <astroco...@gmail.com> wrote: > On Aug 5, 10:14 am, Bennett <juggernau...@gmail.com> wrote: > > > >> On Aug 1, 7:02 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>> On Jul 31, 10:50 am, Bennett <juggernau...@gmail.com> wrote: > >>>> On Jul 31, 7:37 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>>> > On Jul 30, 7:54 am, Bennett <juggernau...@gmail.com> wrote: > >>>> > > On Jul 29, 11:50 am, Jeremy Bailin <astroco...@gmail.com> wrote: > >>>> > > > On Jul 29, 2:32 am, Brian Larsen <balar...@gmail.com> wrote: > >>>> > > > > We do need some more information but this is just screaming for >>>> > > > > histogram. Have a read throughhttp://www.dfanning.com/tips/histogram_tutorial.html >>>> > > > > . Using histogram to see which x's are common you can step through >>>> > > > > the reverse_indices and see which y's are then common. There is >>>> > > > > probably a more graceful way however. > >>>> > > > > Cheers, > >>>> > > > > Brian > >>>> > > > > ------------------------------------------------------------ -------------- >>>> > > > > Brian Larsen >>>> > > > > Boston University >>>> > > > > Center for Space Physicshttp://people.bu.edu/balarsen/Home/IDL > >>>> > > > In particular, if you're dealing with integers that don't span too big >>>> > > > a range, use HIST_2D and find the maximum element. If you've got >>>> > > > floats or a wide range, use UNIQ to turn each into an integer on a >>>> > > > small range first. > >>>> > > > -Jeremy. > >>>> > > I think if I were to be working with small datasets....ie not in the >>>> > > millions of points I would use something like this > >>>> > > coords = [[10,1],[20,32],[5,7],[6,8],[20,32],[2,14],[20,32],[10,10], >>>> > > [3,1],[21,14]] > >>>> > > counter = intarr(9) > >>>> > > FOR i = 0, 8 DO BEGIN >>>> > > FOR j = 0, 8 DO BEGIN > >>>> > > IF array_equal(coords[*,i],coords[*,j]) THEN counter[i]++ > >>>> > > ENDFOR >>>> > > ENDFOR > >>>> > > ;- Histogram to find the max bins (no need to measur…
creator: Juggernaut
date: 2008-08-07T13:21:26-00:00