I have following code in my Mathematica:
P[k_?NumericQ, L_?NumericQ] := P[k, L] = NIntegrate[Exp[I*k*r]*1/r^(2/3), {r, 0, L}];
i = 1;
rhot = {};
a[k_] := RandomVariate[NormalDistribution[0, Sqrt[Re[P[k, 100]]]]] +
I*RandomVariate[NormalDistribution[0, Sqrt[Im[P[k, 100]]]]];
While[i < 3,
alist = Table[a[k], {k, 2*Pi/100, 2*Pi, 2*Pi/100}];
rslist = Fourier[alist];
rhotl = Total[rslist];
Append[rhot, rhot1];
i++]
Unfortunately, the while loop does not give any output. Any idea why this is so?
Table
orAppendTo
. $\endgroup$ – Kuba♦ Aug 25 '16 at 9:01rhot = Append[rhot, Total[rslist]];
Append[]
doesn't actually dynamically change a list, you still need=
. WithAppendTo
you don't need=
$\endgroup$ – Feyre Aug 25 '16 at 9:19