From: nyu on
In trying to set up Manipulate wherein the controlled variable is part
of the iterator in a Do loop or the target in a While loop, I get
sliders but no other output than {Null}. ???????????

From: benson sundheim on

David:

Thank you for your effort in dealing with my question. I'm afraid I
didn't make myself sufficiently clear. My purpose is to study the
rate of convergence of a statistical quantity - I intend to vary the
number of steps varying between 1000 and 100000 looking at the
behavior of the power law characterizing the resulting histograms.
Hence I would like to vary the number of steps in he loop via
Manipiulate.

But

Do[Print[n], {n, 1, 3, 1}] works to produce a output list and

Manipulate[Do[Print[n], {n, 1, rep, 1}], {r, 1, 3}] produces
only a slider and Null.

I observe that there is no error message complaining there is a flaw
in the iterator. Also note that including a specific reference to
rep, such as Print,n,rep}, has no effect. Your further comments would
be appreciated.

Benson Sundheim

From: David Park on
One of the problems I often see in MathGroup is attempting some kind of
complicated calculation inside some high level operation, such as Plot or
Manipulate, without sufficiently testing out the calculation by itself, and
making certain it produces what is required for the higher level operation.

I'm not completely certain of your objective but I hope this will be close
enough.

Here is a routine, f, that I believe carries out your calculation.

f[n_Integer?Positive][t_Integer?Positive] :=
Module[
{n1, n2, list = Table[5, {n}]},
Do[
n1 = RandomInteger[{1, n}];
n2 = RandomInteger[{1, n}];
If[n1 != n2 && list[[n2]] != 0, {list[[n1]] = list[[n1]] + 1,
list[[n2]] = list[[n2]] - 1}], {t}];
list]

You can test it with various cases.

f[6][3]
{4, 4, 7, 4, 6, 5}

Then it is easy to write a Manioulate:

Manipulate[
f[6][t],
{t, 1, 5, 1, Appearance -> "Labeled"}]

But probably better here would be a SetterBar.

Manipulate[
f[6][t],
{{t, 1}, SetterBar[Dynamic[t], Range[10]] &}
]


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/


From: benson sundheim [mailto:nyuout(a)optonline.net]


On Feb 22, 2010, at 8:01 AM, David Park wrote:

> A Do statement doesn't have any output so you would need something
> more.
>
> Maybe you could first write and test outside the Manipulate a
> routine with
> the control variable q:
>
> f[q_]:=...
>
> Then if that works and produces the display you want put it in the
> Manipulate.
>
> Otherwise post a specific example.
>
>
> David Park
> djmpark(a)comcast.net
> http://home.comcast.net/~djmpark/
>
>
> From: nyu [mailto:nyuout(a)optonline.net]
>
> In trying to set up Manipulate wherein the controlled variable is part
> of the iterator in a Do loop or the target in a While loop, I get
> sliders but no other output than {Null}. ???????????
>
>
e.g.;
n = 10;
list = Table[5, {n}];
Manipulate[
{Do[
{
n1 = Random[Integer, {1, n}],
n2 = Random[Integer, {1, n}],
If[n1 != n2 && list[[n2]] != 0, {list[[n1]] = list[[n1]] + 1,
list[[n2]] = list[[n2]] - 1}], Print[list]
}, {i, 1, t, 1}
]}, {t, 1, 5, 1}
]


From: dh on
Hi Benson,
manipulate has the following syntax:
Manipulate[expression,iterator]
Now consider the output of your expression: Do[Print[n], {n, 1, 3, 1}].
"Do" always returns nothing, that is "Null". The output of "Print" is a
side effect and goes to the message stream. Therefore, what is shown
inside Manipulate is "Null". Therefore, you need to produce sokme output
to display. You could e.g. use Table:

Manipulate[Table[n, {n, 1, rep}], {rep, 1, 3}]

Daniel

On 23.02.2010 01:03, benson sundheim wrote:
> David:
>
> Thank you for your effort in dealing with my question. I'm afraid I
> didn't make myself sufficiently clear. My purpose is to study the
> rate of convergence of a statistical quantity - I intend to vary the
> number of steps varying between 1000 and 100000 looking at the
> behavior of the power law characterizing the resulting histograms.
> Hence I would like to vary the number of steps in he loop via
> Manipiulate.
>
> But
>
> Do[Print[n], {n, 1, 3, 1}] works to produce a output list and
>
> Manipulate[Do[Print[n], {n, 1, rep, 1}], {r, 1, 3}] produces
> only a slider and Null.
>
> I observe that there is no error message complaining there is a flaw
> in the iterator. Also note that including a specific reference to
> rep, such as Print,n,rep}, has no effect. Your further comments would
> be appreciated.
>
> Benson Sundheim
>


--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh(a)metrohm.com>
Internet:<http://www.metrohm.com>