10
$\begingroup$

How do you add a refresh button to

Manipulate[RandomVariate[BernoulliDistribution[p], 10], {p, 0, 1}]

that will re-evaluate RandomVariate[BernoulliDistribution[p], 10] when clicked?

$\endgroup$

2 Answers 2

6
$\begingroup$

The following works :

   Manipulate[
     Typeset`update$$; 
     RandomVariate[BernoulliDistribution[p], 10], {p, 0, 1},
     AppearanceElements -> "UpdateButton"]

enter image description here

To update press the button "U" at the top-right.
Of course, if you move the cursor it updates too.

$\endgroup$
8
$\begingroup$
Manipulate[
 r; 
 RandomVariate[BernoulliDistribution[p], 10], 
 {p, 0, 1}, {{r, True}, None},
 Button["refresh", r = ! r]]

Out

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.