This is what I would do:
my $max = [ $x[ 0 ], $y[ 0 ] ]; for my $i ( 1..$#x ) { last if $y[ $i ] <= $max[ 1 ]; $max = [ $x[ $i ], $y[ $i ] ]; } print "max at ($max->[ 0 ], $max->[ 1 ])\n";
This code makes two important assumptions: that your data is ordered in the x-axis and that it is really as smooth as you describe it. If neither of these two assumptions hold, the following would be better:
my $max = [ $x[ 0 ], $y[ 0 ] ]; for my $i ( 1..$#x ) { $max = [ $x[ $i ], $y[ $i ] ] if $y[ $i ] > $max->[ 1 ]; } print "max at ($max->[ 0 ], $max->[ 1 ])\n";
the lowliest monk
In reply to Re: Any idea for predicting the peak points in the graph by perl
by tlm
in thread Any idea for predicting the peak points in the graph by perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |