This is probably really a simple question.
I would like to plot a sum of cosines with increased argument and for each cosine in sum I would like to add random value:
Plot[Sum[Cos[n*x + RandomReal[{0, 2 Pi}]], {n, 100}], {x, -10, 10}]
However it seems to me that the program, while making a plot, generates a new random number for each x-point plotted. Therefore, even for single cosine (Plot[Cos[x + RandomReal[{0, 2*Pi}]], {x, -10, 10}]
) I get a completely noisy graph of random cosine values.
I would be very grateful if somebody can tell me what to do to prevent the program from generating new random numbers at each x-point.
With[{r = RandomReal[{0, 2 Pi}]}, Plot[Cos[x + r], {x, -10, 10}]]
$\endgroup$With[{r = RandomReal[{0, 2 Pi}, 10]}, Plot[Total[Cos[Range[10] x + r]] // Evaluate, {x, -10, 10}]]
$\endgroup$