Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Questions lke this tend to require some defintion of "proximity" which is rarely as simple as "N points within a polygon or area M" ... typically people want to find trends -- 3 problems within 1 grid square is a trend, 1 is not -- BUT! 1 per grid square for 10x10 grid squares is.

An algorithm that seems like it would work well, assumes that you have a range of "region sizes" that can overlap, and difffernet thresolds for the number of problems that constitute a "hot spot region". In psuedo code...

%grid_size_thresholds = ( 1 => 3, # a 1x1 square grid is hot if it has 3 probs 2 => 10,# a 2x2 square grid is hot if it has 10 probs 3 => 30,# ... ... ) @hotspots = (); foreach $size (sort keys %grid_size_thresholds) { for ($x = 0; $x + $size < $GRID_WIDTH; $x++) { for ($y = 0; $y + $size < $GRID_HEIGHT; $y++) { $region = new Region($x, $x + $size, $y, $y + $size); $prob_count = get_num_probs_in_region($region); if ($grid_size_thresholds{$size} <= $prob_count) { push @hotspots, $region; } } } }
You now have a list of (possibly nested) square regions of various sizes which identify hotspots. You can eliminate regions which are completely contained by other regions in the list, or you could use the info to find "hot spots within warm spots" (ie: "region 1,4;2,3 has had enough problems to deserve attention, and within that 1,2;2,3 desrves special attention)


In reply to Re: Sorting by geographical proximity / clumping groups of items based on X and Y by hossman
in thread Sorting by geographical proximity / clumping groups of items based on X and Y by vroom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-12-08 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?