For numerical data tehre are some minor modifications necessary:
(* Original data *)
xx = Range[10];
yy = Table[j^2 + RandomReal[{-10, 10}], {j, 1, 10}];
bigmat = Transpose[{xx, yy}]
smallmat = bigmat[[#]] & /@ {2, 5, 9}
pl1 = ListLinePlot[bigmat, PlotRange -> {-10, 110},
AxesOrigin -> {0, 0}, PlotStyle -> Black]
(* "subtract" smallmat from bigmat *)
cc = Complement[bigmat, smallmat]
cc1 = Complement[bigmat, smallmat,
SameTest -> (Sqrt[(#1 - #2).(#1 - #2)] < .0001 &)]
(*method average around spike*)
index = Function[{x}, Position[bigmat, x][[1, 1]]] /@ smallmat
sublists =
DeleteCases[bigmat[[Max[1, # - 2] ;; Min[Length[bigmat], # + 2]]],
bigmat[[#]]] & /@ index
meanvals =
Function[{x}, Total[Transpose[x][[2]]]/Length[x]] /@ sublists;
(*add the x-vals*)
corrvals = Transpose[{bigmat[[#]][[1]] & /@ index, meanvals}]
rule = Table[smallmat[[i]] -> corrvals[[i]], {i, 1, Length[smallmat]}]
bigmatnew = bigmat /. rule
pl2 = ListLinePlot[bigmatnew, PlotRange -> {-10, 110},
AxesOrigin -> {0, 0}, PlotStyle -> Red]
(* method with interpolation *)
index = Function[x, Position[bigmat, x][[1, 1]]] /@ smallmat
index1 = {Max[1, # - 1], #, Min[Length[bigmat], # + 1]} & /@ index
val = Map[bigmat[[#]] &, index1, {2}]
nval = Function[{a, b, c},
{b[[1]],
a[[2]] (b[[1]] - c[[1]])/(a[[1]] - c[[1]]) +
c[[2]] (b[[1]] - a[[1]])/(c[[1]] - a[[1]])}] @@@ val
rule = Table[smallmat[[i]] -> nval[[i]], {i, 1, Length[smallmat]}]
bigmatnew = bigmat /. rule
pl3 = ListLinePlot[bigmatnew, PlotRange -> {-10, 110},
AxesOrigin -> {0, 0}, PlotStyle -> Blue]
(* show them all *)
Show[pl1, pl2, pl3]