0
$\begingroup$

I have a code that works well. The code has been show below.

I want to switch the input 'k1' from being being a single value input to a slider between 0 and 1 in steps of 0.1. What would be the best way to do that? Would it be the use of 'Manipulate' or would it be some other function?

Thank you!

Sid

   CloudDeploy[
 FormPage[{"k1" -> "Number", "n1" -> "Number", "n2" -> "Number"},
  
  (fig1 = 
     SmoothHistogram[
      Table[Table[
        If[RandomReal[] > #k1, RandomChoice[{100, 90}], 
         RandomChoice[{80, 70, 60, 50, 40}]], #n1], #n2], 
      PlotStyle -> Red]; 
    Show[{fig1}]) &
  ]

]

$\endgroup$
1
$\begingroup$

Use a Slider control

FormPage[{"k1" -> <|"Interpreter" -> Restricted["Real", {0, 1, .1}], 
    "Control" -> Slider|>, "n1" -> "Number", 
  "n2" -> 
   "Number"}, (fig1 = 
    SmoothHistogram[
     Table[
      Table[
       If[RandomReal[] > #k1, RandomChoice[{100, 90}], 
        RandomChoice[{80, 70, 60, 50, 40}]], #n1], #n2], 
     PlotStyle -> Red];
   Show[{fig1}]) &]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you! That works perfectly. $\endgroup$ – Sid Gopujkar May 27 at 3:05
  • 1
    $\begingroup$ You are welcome. Would you mind accepting the answer? $\endgroup$ – Rohit Namjoshi May 27 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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