If the coordinates are integral and fewer than a few tens of million then you could simply generate a hash which uses coordinates as keys and averages as values then its a simple matter of looking up the hash for each marker:

use strict; use warnings; use lib 'C:\Users\Peter\Tools\BuildManager'; my $data = <<DATA; 12345 12445 0.454 12346 12446 0.326 12347 12447 0.355 DATA my $markers = <<MARKERS; 12435 13455 13532 16135 MARKERS my %dataLU; open my $dataIn, '<', \$data; while (defined (my $line = <$dataIn>)) { chomp $line; my ($start, $end, $avg) = split ' ', $line; $dataLU{$_}{sum} += $avg for $start .. $end; ++$dataLU{$_}{count} for $start .. $end; } close $dataIn; open my $markersIn, '<', \$markers; while (defined (my $line = <$markersIn>)) { chomp $line; next if ! length $line; if (! exists $dataLU{$line}) { print "No value for $line\n"; next; } printf "Marker $line: %f\n", $dataLU{$line}{sum} / $dataLU{$line}{ +count}; } close $markersIn;

Prints:

Marker 12435: 0.378333 No value for 13455 No value for 13532 No value for 16135
True laziness is hard work

In reply to Re: Sliding window intervals and average values for specific coordinates by GrandFather
in thread Sliding window intervals and average values for specific coordinates by Renyulb28

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.