Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the output of a large computer simulation(thousands of cpus for 3 days), I found that one data point is missing in the result. Is it possible to reconstruct the missing value using the remaining data?

Assumptions: The dynamics in the data is generally smooth and there is no shape feature in it.

Here is the data:


Also from other output information, I can determined that the problem data is at the index 51, which is set to 0 in the above.

So is it possible to reconstruct that value?

Here is my try:

I use the wavelet transform to identify the abrupt changes in the data, and manually adjust the data value, until I get a relative smooth wavelet transform.

 data1 = data;
 data1[[51]] = data[[51]] + Abs[Mean[{data[[50]], data[[52]]}]]*x;
 cwd = ContinuousWaveletTransform[data1, 
   GaborWavelet[10], {Automatic, 12}];
 values = Abs[cwd[All, "Values"]];
 ListDensityPlot[values, ColorFunction -> "TemperatureMap", 
  PlotRange -> {All, {0, 50}, {0, 0.1 Max[values]}}, 
  ClippingStyle -> Automatic, InterpolationOrder -> 0]
 {x, -10, 30, 1}

enter image description here

Form above I determined by eye that when x=17 the wavelet is smoothest. So the missing data I get is 0.377765. And here is a plot of the data and the wavelet transform after the fix

enter image description here enter image description here


  1. What are the general ways of reconstruct missing data?
  2. Are there other methods to reconstruct the missing data, without looking by eye?
share|improve this question
Related: Interpolating 2D data with missing values – Rahul Nov 23 '13 at 3:52
Update: I tried the approach in that question, but it doesn't work too well thanks to the rapid oscillation in the data. Only with InterpolationOrder -> 100 does it get close to the expected result, and with even higher orders it becomes unstable. – Rahul Nov 23 '13 at 4:00
Very nice idea indeed to use animation for manual determination of "the best" value! – Dragan Mrakovic Nov 23 '14 at 13:16
up vote 11 down vote accepted

I don't think there are "general methods". Normally interpolation or curve fitting can be used.

Let's see your particular problem. You have five distinct samplings:

ListLinePlot[data[[# ;; -1 ;; 5]] & /@ Range@5]

enter image description here

The first one shows the problem:

ListLinePlot[data[[1 ;; -1 ;; 5]]]

enter image description here

Let's see which point is the outlier:

First@Ordering[-Abs@Differences@data[[1 ;; -1 ;; 5]]]

Let's calculate a "right" value

Mean[{data[[1 ;; -1 ;; 5]][[10]], data[[1 ;; -1 ;; 5]][[12]]}]

And now we replace it in the original sequence

ListLinePlot@ ReplacePart[data, Position[data, 0.][[1]] -> 0.37620699999999996`]

enter image description here


If you want a slightly better approximation, you could do something like:

pata = Transpose[{Range@Length@data, data}]; 
Interpolation[Join[pata[[1 ;; -1 ;; 5]][[5 ;; 10]], 
                   pata[[1 ;; -1 ;; 5]][[12 ;; 18]]]][51]

share|improve this answer
That's clever. How do you determine the number 5? What do you mean by "five distinct samplings"? – xslittlegrass Nov 23 '13 at 0:00
@xslittlegrass Your sampling freq is almost five times the highest freq of the signal. You are sampling five times each period – Dr. belisarius Nov 23 '13 at 0:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.