# How to detect the singular value with signal processing technology?

I have a signal like

signal={1.00,1.10,1.22,1.34,1.48,1.62,1.76,1.90,2.05,2.19,2.32,2.44,2.54,2.62,2.68,2.71,2.72,2.70,2.65,4.00,4.00,2.37,2.24,2.11,1.96,1.82,1.67,1.53,1.40,1.27,1.15,1.04,0.94,0.85,0.77,0.70,0.64,0.59,0.54,0.50,0.47,0.44,0.42,0.40,0.39,0.38,0.37,0.37,0.37,0.37,0.38,0.40,0.41,0.44,0.46,0.49,0.53,0.58,0.63,0.69,0.76,0.83,0.92,1.02,1.12,1.24,1.37,1.50,1.64,1.78,1.93,2.07,2.21,2.34,2.46,2.55,2.63,2.69,2.71,2.72,2.69,2.64,2.56,2.46,2.35,2.22,2.08,1.94,1.79,1.65,1.51,1.38,1.25,1.13,1.03,0.93,0.84,0.76,0.69,0.63,0.58,0.54,0.50,0.46,0.44,0.41,0.40,0.38,0.37,0.37,0.37,0.37,0.38,0.39,0.40,0.42,0.44,0.47,0.50,0.54,0.58,0.64,0.70,0.77,0.85,0.94,1.03,1.14,1.26,1.39,1.52,1.66,1.81,1.95,2.10,2.23,2.36,2.47,2.57,2.64,2.69,2.72,2.71,2.68,2.63,2.55,2.45,2.33,2.20,2.06,1.92,1.77,1.63,1.49,1.35,1.23,1.11,1.01,0.91,0.83,0.75,0.68,0.62,0.57,0.53,0.49,0.46,0.43,0.41,0.39,0.38,0.37,0.37,0.37,0.37,0.38,0.39,0.40,0.42,0.44,0.47,0.51,0.55,0.59,0.65,0.71,0.78,0.86,0.95,1.05,1.16,1.28,1.41,1.55,1.69,1.83,1.98,2.12,2.26,2.38,2.49}

If I plot it,its graphics will be

As the graphics,we can see there are two singular values in 20 or 21 approximately.I want to use techonology of wavelet analysis to find it.How to do it?Actually I can do it by Mathematica,my answer is here.But I'm looking forward a better solution.Anyone could use any promgram,like python,matlab or other something.

• Why do you want to use wavelet transform? are other signal processing techniques allowed? – Maximilian Matthé Apr 26 '17 at 3:53
• @MaximilianMatthé You can have a try if the effect is good – yode Apr 26 '17 at 4:38

Use e.g. median filtering to detect the outliers (code in python):

data=np.array([1.00,1.10,1.22,1.34,1.48,1.62,1.76,1.90,2.05,2.19,2.32,2.44,2.54,2.62,2.68,2.71,2.72,2.70,2.65,4.00,4.00,2.37,2.24,2.11,1.96,1.82,1.67,1.53,1.40,1.27,1.15,1.04,0.94,0.85,0.77,0.70,0.64,0.59,0.54,0.50,0.47,0.44,0.42,0.40,0.39,0.38,0.37,0.37,0.37,0.37,0.38,0.40,0.41,0.44,0.46,0.49,0.53,0.58,0.63,0.69,0.76,0.83,0.92,1.02,1.12,1.24,1.37,1.50,1.64,1.78,1.93,2.07,2.21,2.34,2.46,2.55,2.63,2.69,2.71,2.72,2.69,2.64,2.56,2.46,2.35,2.22,2.08,1.94,1.79,1.65,1.51,1.38,1.25,1.13,1.03,0.93,0.84,0.76,0.69,0.63,0.58,0.54,0.50,0.46,0.44,0.41,0.40,0.38,0.37,0.37,0.37,0.37,0.38,0.39,0.40,0.42,0.44,0.47,0.50,0.54,0.58,0.64,0.70,0.77,0.85,0.94,1.03,1.14,1.26,1.39,1.52,1.66,1.81,1.95,2.10,2.23,2.36,2.47,2.57,2.64,2.69,2.72,2.71,2.68,2.63,2.55,2.45,2.33,2.20,2.06,1.92,1.77,1.63,1.49,1.35,1.23,1.11,1.01,0.91,0.83,0.75,0.68,0.62,0.57,0.53,0.49,0.46,0.43,0.41,0.39,0.38,0.37,0.37,0.37,0.37,0.38,0.39,0.40,0.42,0.44,0.47,0.51,0.55,0.59,0.65,0.71,0.78,0.86,0.95,1.05,1.16,1.28,1.41,1.55,1.69,1.83,1.98,2.12,2.26,2.38,2.49])
data_index = np.arange(len(data), dtype=int)

### Outlier detection begin
filtered = signal.medfilt(data, 5)
diff = abs(data - filtered)
meandiff = np.mean(diff)
stddiff = np.std(diff)
outliers = diff > (meandiff + 3*stddiff)
print ("Outlier indices:", data_index[outliers])
### Outlier detection end

plt.plot(data_index, data, label='data')
plt.plot(data_index, filtered, label='filtered')
plt.plot(data_index[outliers], data[outliers], 'ro', label='detected outliers')
plt.legend()
plt.ylim((0,5)); plt.grid(True)


• Thanks very much,if there is not better method,I will accept it. :) – yode Apr 26 '17 at 10:32