I'm not quite sure what you mean by your last sentence as I wouldn't have thought all the markers in one particular window will all be members of the same windows. Anyway, is this something like what you are trying to do?

use strict; use warnings; use 5.010; use List::Util qw{ sum }; use Data::Dumper; open my $windowsFH, q{<}, \ <<EOD or die qq{open: < HEREDOC: $!\n}; 10 19 0.287 11 20 0.502 12 21 0.462 13 22 0.407 14 23 0.254 15 24 0.335 16 25 0.474 EOD my %values; while ( <$windowsFH> ) { my( $min, $max, $value ) = split; push @{ $values{ $_ } }, $value for $min .. $max; } close $windowsFH or die qq{close: < HEREDOC: $!\n}; print Data::Dumper ->Dumpxs( [ \ %values ], [ qw{ *values } ] ); open my $markersFH, q{<}, \ <<EOD or die qq{open: < HEREDOC: $!\n}; 12 15 17 EOD while ( <$markersFH> ) { chomp; say qq{$_ - }, ( sum @{ $values{ $_ } } ) / @{ $values{ $_ } }; } close $markersFH or die qq{close: < HEREDOC: $!\n};

The output.

%values = ( '25' => [ '0.474' ], '11' => [ '0.287', '0.502' ], '21' => [ '0.462', '0.407', '0.254', '0.335', '0.474' ], '17' => [ '0.287', '0.502', '0.462', '0.407', '0.254', '0.335', '0.474' ], '12' => [ '0.287', '0.502', '0.462' ], '20' => [ '0.502', '0.462', '0.407', '0.254', '0.335', '0.474' ], '15' => [ '0.287', '0.502', '0.462', '0.407', '0.254', '0.335' ], '14' => [ '0.287', '0.502', '0.462', '0.407', '0.254' ], '22' => [ '0.407', '0.254', '0.335', '0.474' ], '18' => [ '0.287', '0.502', '0.462', '0.407', '0.254', '0.335', '0.474' ], '24' => [ '0.335', '0.474' ], '23' => [ '0.254', '0.335', '0.474' ], '19' => [ '0.287', '0.502', '0.462', '0.407', '0.254', '0.335', '0.474' ], '10' => [ '0.287' ], '13' => [ '0.287', '0.502', '0.462', '0.407' ], '16' => [ '0.287', '0.502', '0.462', '0.407', '0.254', '0.335', '0.474' ] ); 12 - 0.417 15 - 0.3745 17 - 0.388714285714286

I hope this is helpful.

Cheers,

JohnGG


In reply to Re: Sliding window intervals and average values for specific coordinates by johngg
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.