Collaboration with interpolated functions in mathematics

I am using Mathematica 7.

I have an interpolated function, here is an example:

pressures = 
  WeatherData["Chicago", "Pressure", {2010, 8}] // 
     DeleteCases[#, {_, _Missing}] & // 
    Map[{AbsoluteTime[#[[1]]], #[[2]]} &, #] & // Interpolation;

I would like to calculate its derivative, which is straightforward:

dpressures = D[pressures[x], x]

Now if you build this funciton

Plot[3600*dpressures, {x, AbsoluteTime[{2010, 8, 2}], AbsoluteTime[{2010, 8, 30}]}]

(Sorry, I don’t know how to publish the image from Mathematica, and you don’t have time to figure it out.) You will find that it is very noisy. So I would like to smooth this out. My first thought was to use Convolve and integrate it with the Gaussian kernel, something like the following:

a = Convolve[PDF[NormalDistribution[0, 5], x], 3600*dpressures, x, y]

Returns

360 Sqrt[2/\[Pi]] Convolve[E^(-(x^2/50)), InterpolatingFunction[{{3.48961266 10^9, 3.49228746 10^9}},<>], ][x], x, y]

Which looks reasonable to me. Unfortunately, I believe that I made a mistake somewhere, because the result that I return does not seem to be appreciated. I.e:

a /. y -> AbsoluteTime[{2010, 8, 2}]

Returns

360 Sqrt[2/\[Pi]] Convolve[E^(-(x^2/50)), InterpolatingFunction[{{3.48961266 10^9, 3.49228746 10^9}},<>][x], x, 3489696000]]

Which is just not what I was looking for, I expect a number from -1 to 1.

+3
1

Convolve . , -

NConvolve[f_, g_, x_, y_?NumericQ] := 
 NIntegrate[f (g /. x -> y - x), {x, -Infinity, Infinity}]

. ( .)

, .

:

In[89]:= {lower = Min[First[pressures]], upper = Max[First[pressures]]}    
Out[89]= {3.48961*10^9, 3.49229*10^9}

*:

data = Table[pressures[x], {x, lower, upper, 3600}];

ListLinePlot[Differences[data]]

5- :

ListLinePlot[GaussianFilter[Differences[data], 5]]
  • InterpolationOrder β†’ 1 .
+5

Source: https://habr.com/ru/post/1766485/


All Articles