# How to detect the singular value with wavelet analysis

I have a series data

data=Uncompress[
FromCharacterCode[Flatten[ImageData[Import["http://i.stack.imgur.com/ApipY.png"],
"Byte"]]]];


We can show it

ListPlot[data, PlotRange -> All]


I put a singular value in position $20$ and $21$.As I know,wavelet analysis can detect it,but I don't know how to do it.

Of course expected more professionnel answer,I just dig in documentation

Firstly,plots wavelet transform coefficients

dwd = DiscreteWaveletTransform[data];
WaveletListPlot[dwd]


Select that basis index with minimal energy

{basisIndex} = Keys[MinimalBy[dwd["EnergyFraction"], Last]]


{{0, 1}}

Ugly to extract that x-value.

MaximalBy[
Cases[basisIndex /. dwd["ListPlot"], a_Line :> a, Infinity][[1,1]], Abs@*Last]


{{20.1, 1.00915}}

Simple way not using wavelet

Position[data - MedianFilter[data, 3], x_ /; x > 1]


{{20}, {21}}

• Thanks very much,but I have to say,it hard to find that threshold form those difference value – yode Sep 18 '17 at 12:22
• If you don't like picking an amplitude for the threshold, then just pick the Position of the largest (absolute) value of data-MedianFilter. – bill s Sep 18 '17 at 12:31