Mathematica Asked by Hans W on April 16, 2021
The examples for using MovingAverage mostly refer to data evenly spaced in time,such as stock values. In typical physics data, events arrive random in time (e.g. radio active decay events, but also if acting in day trading on the stock market). I do not see how I can use the apparatus of MovingAverage and associated evaluations in this case. Do I not understand the function, or should I go ahead and invent my own functions?
By default the MovingAverage
could be applied for 1-D lists but regarding to your case, you need make the TemporalData
from your {t,y}
list:
y= Table[RandomReal[{-1, 1}] + 5 Sin[i/(6 Pi)], {i, 1, 100}];
t = Table[i + RandomReal[{-0.3, 0.3}], {i, 1, 100}]; (*As you see, the timestamps contain random shifts*)
td = TemporalData[y, {t}];
ListPlot[{td, MovingAverage[td, 5]},
PlotMarkers -> {Automatic, None},
Joined -> {False, True},
ImageSize -> 800,
PlotStyle -> {Directive[Lighter[Blue, 0.5]],
Directive[Red, Thick]}]
Answered by Rom38 on April 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP