1

下面的代码用于在 Mathematica 中数值求解一个粒子的随机方程。我想知道是否有一种方法可以将其推广到多个粒子的情况并对其进行平均。有谁知道该怎么做?

Clear["Global`*"]
{ a = Pi, , b = 2 Pi, l = 5, k = 1};
ic = x@tbegin == 1;
tbegin = 1;
tend = 400;
interval = {1, 25};
lst := NestWhileList[(# + RandomVariate@TruncatedDistribution[interval, 
StableDistribution[1, 0.3, 0, 0, 1]]) &, tbegin, # < tend &];
F[t_] := Piecewise[{{k, Or @@ #}}, -k] &[# <= t < #2 & @@@ 
Partition[lst, 2]];
eqn := x'[t] == (F@(t)) ;
sol = NDSolveValue[{eqn, ic}, x, {t, tbegin, tend}, 
MaxSteps -> Infinity];

Plot[sol@t, {t, tbegin, tend}]
First[First[sol]]
Plot[sol'[t], {t, tbegin, tend}]
Plot[F[t], {t, tbegin, tend}]
4

0 回答 0