Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How do I find peaks in noisy data?

by BrowserUk (Patriarch)
on Apr 26, 2006 at 23:52 UTC ( [id://545909]=note: print w/replies, xml ) Need Help??


in reply to How do I find peaks in noisy data?

Sounds like you need a high-pass filter. Specifying the cut-off as a percentage and normalising the values should allow for variable s/n ratios.

#! perl -slw use strict; use List::Util qw[ max ]; sub islands { my( $percent, $dataRef ) = @_; my $max = max @$dataRef; my $filtered = join '', map{ ( $_ / $max ) > $percent ? 1 : 0 } @$dataRef; printf "%4.2f : %s\n", $percent, $filtered; } my @data = split ' ', do{ local $/; <DATA> }; islands $_, \@data for map{ $_ / 20 } 1 .. 20; =comment c:\test>545901 0.05 : 0000000111111111100001 0.10 : 0000000011111111000000 0.15 : 0000000001111111000000 0.20 : 0000000001111110000000 0.25 : 0000000000111110000000 0.30 : 0000000000111110000000 0.35 : 0000000000111110000000 0.40 : 0000000000111100000000 0.45 : 0000000000111100000000 0.50 : 0000000000111100000000 0.55 : 0000000000111100000000 0.60 : 0000000000111100000000 0.65 : 0000000000011000000000 0.70 : 0000000000011000000000 0.75 : 0000000000011000000000 0.80 : 0000000000011000000000 0.85 : 0000000000011000000000 0.90 : 0000000000011000000000 0.95 : 0000000000010000000000 1.00 : 0000000000000000000000 =cut __DATA__ 101 203 321 45 67 156 203 502 899 2003 5007 8020 7301 5030 3045 1243 567 321 234 45 123 453

You could enhance that by adding a minimum width to exclude transient spikes like the one shown at the end of the 5% line. Turning the 0s & 1s back into either groups of values or index ranges is fairly easy depending upon what you need to do with the islands once isolated.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://545909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-19 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found