       Dynamic Module

• To: mathgroup at smc.vnet.net
• Subject: [mg95943] Dynamic Module
• From: John <jwa0 at lehigh.edu>
• Date: Fri, 30 Jan 2009 05:45:28 -0500 (EST)

Mathematica 6 help has an example of a dynamic module used to
construct a dynamic calculating interface. I used it to create a
calculating interface that simulated X (the number of bad units in a
sample) when X has the binomial distribution with parameters n (sample
size) and p (the binomial probability). Values of n and p are entered
in input fields and the answer appears in a third field.

It works, but not perfectly. The binomial distribution is momentarily
confused when  new values of n and p are entered, apparently because,
for a second or two, n and p have no values. Once the new values are
entered, the confusion ends and the answer appears.

I have not yet found a way to change font size in the fields. As it
is, the font is too small when the panel is projected on a screen.

My dynamic model is listed below:

DynamicModule[{n, p},
Deploy[Style[
Panel[Grid[
Transpose[{{Style["enter n", 20], Style["enter p", 20],
Style["simulated X", 20]}, {InputField[Dynamic[n], Number],
InputField[Dynamic[p], Number],
InputField[
Dynamic[ Total[RandomInteger[BinomialDistribution[n, p], 1]],
Number], Enabled -> False]}}], Alignment -> Right],
ImageMargins -> 10],
DefaultOptions -> {InputField -> {ContinuousAction -> True,
FieldSize -> {{5, 30}, {1, Infinity}}}}]]]

What does Alignment-> Right do? I changed it to left, and the
appearance of the panel was exactly the same.

Any suggestions will be greatly appreciated.

John

• Prev by Date: Re: Frame does not show up?
• Next by Date: Re: mathematica's syntax is very like lisp language
• Previous by thread: Re: Synchronous zooming of 3D graphics
• Next by thread: Can I Map[] this code?