I have a list variable that I want to append new values from a normal distribution to after I click a button. It works in a simple case but not for the more complicated situation and I don't know why.
This works.. When I run it and press Start I can see the dynamic signal variable gets an extra '1' appended to the list every second.
signal = {};
DynamicModule[{task, μ, σ},
task = CreateScheduledTask[AppendTo[signal, 1], 1];
μ = 10;
σ = 1;
Panel[Grid[
{{Button["Start", StartScheduledTask[task]], Null},
{Button["Stop", StopScheduledTask[task]], Null},
{"μ", Slider[Dynamic[μ], {0, 50}], Dynamic[μ]},
{"σ", Slider[Dynamic[σ], {0, 10}], Dynamic[σ]}
}, Dividers -> {False, {False, False, True}}]]
]
Dynamic[signal]
But what I'm actually interested in is appending a random variate from a normal distribution to the list. So I change the task variable to:
task = CreateScheduledTask[AppendTo[signal,
RandomVariate[NormalDistribution[μ, σ]]], 1]
But this doesn't work. Nothing is appended to the list.
taskand the assignment of the values to $\mu$ and $\sigma$? I suspect that $\mu$ and $\sigma$ are not defined whentask=...is executed the first time. – Felix Jan 29 '17 at 02:27