RE: Button Question

*To*: mathgroup at smc.vnet.net*Subject*: [mg84342] RE: [mg84319] Button Question*From*: "Ingolf Dahl" <ingolf.dahl at telia.com>*Date*: Wed, 19 Dec 2007 23:58:32 -0500 (EST)*Organization*: Goteborg University*References*: <200712190910.EAA13570@smc.vnet.net>*Reply-to*: <ingolf.dahl at telia.com>

John, It works perfectly well if you paste the following in Mathematica 6.0 (choose to interpret the text!) Cell[ButtonBox["Simulate", Active -> True, ButtonFunction -> (Needs["MultivariateStatistics`"]; Print[RandomInteger[ MultivariateStatistics`MultinomialDistribution[ 100, {1/6,1/6,1/6,1/6,1/6,1/6}], 1]]), ButtonEvaluator -> Automatic] // DisplayForm, "Output"] Thus avoid the quotes around 1/6. The arrow with colon (RuleDelayed) is generated by :> . I do not think it is needed here. You could also try to execute the following code Button["Simulate", Needs["MultivariateStatistics`"]; Print[RandomInteger[ MultivariateStatistics`MultinomialDistribution[ 100, {1/6,1/6,1/6,1/6,1/6,1/6}], 1]]] (The printed line is then overwritten each time the button is pressed) Best regards Ingolf Dahl -----Original Message----- From: John [mailto:jwa0 at lehigh.edu] Sent: 19 December 2007 10:11 To: mathgroup at smc.vnet.net Subject: [mg84342] [mg84319] Button Question The cell, pasted below, is in my notebook. When the cell is evaluated, It prints a button, labeled simulate, but clicking on the button does not print the six simulated integers that RandomInteger computed. The error message says that the list of probabilities, entered as shown below, is not a probability distribution recognized by the system, but {1/6,1/6,1/6,1/6,1/6,1/6} is a valid multinomial distribution. ButtonEvaluator, not mispelled, is printed in red. The color red must be an indication of an error of some kind, but I have no idea what it is. Cell[ButtonBox["Simulate", Active -> True, ButtonFunction -> Print[RandomInteger[ MultinomialDistribution[ 100, {"1", "/", "6", "1", "/", "6", "1", "/", "6", "1", "/", "6", "1", "/", "6", "1", "/", "6"}], 1]], ButtonEvaluator -> Automatic] // DisplayForm, "Output"], In one example, I saw, the arrow between ButtonFunction and Print is short and preceded by a colon. If if that notation is necessary, I don't know how to do it. Helpful advice will be appreciated . John

**References**:**Button Question***From:*John <jwa0@lehigh.edu>