Wolfram Language

Core Language

Smooth a Simulated Particle Trajectory

Use a combination of BlockMap and TrimmedMean to smooth out data from a particle trajectory.

Simulate a stochastic path by adding noise to an exact trajectory.

In[1]:=
Click for copyable input
exact[u_] := {u Cos[u], u Sin[u]} noise[u_] := RandomReal[CauchyDistribution[0, 1], 2] data = Table[exact[u] + noise[u], {u, 0, 6 \[Pi], 1/100}];
In[2]:=
Click for copyable input
ListPlot[data, AspectRatio -> Automatic]
Out[2]=

Smooth the simulated trajectory with BlockMap using a moving TrimmedMean to eliminate possible outliers.

In[3]:=
Click for copyable input
smooth[r_] := BlockMap[TrimmedMean, data, r, 1]

Increase the window size to get a smoother trajectory.

In[4]:=
Click for copyable input
Table[ListPlot[smooth[r], AspectRatio -> Automatic], {r, {25, 50, 100, 200}}]
Out[4]=

Related Examples

de es fr ja ko pt-br ru zh