My goal is to implement the three things below.
(i) Number of white balls(w ) and red balls(r) are constrained to be 2 ~ 29.
(ii)Total number(n) of balls is w+r and it shoud not exceed 30.
(iii)sampleSize is constrained to be at least 1 and at most n-1.
My code is as below;
Manipulate[n = w + r;
If[2 <= n <= 30,
Grid[{{"w", "r", "n=w+r", "sampleSize=n-1"}, {w, r, n, sampleSize}},
Frame -> All], "not adjustable, w+r lager than 30"], {{w, 1}, 1,
29, 1}, {{r, 1}, 1, 29, 1}, {sampleSize, 1, n - 1, 1},
ControlPlacement -> Left]
There are two problem to my code.How to improve?
- My sampleSize was exceeding n-1 as below, violating (iii).
- To implement (ii), is there a way to limit the maximum of w and r sliders so that w+r is always less than 29 whenever moving the w or r sliders? (I have used message to appear as below using If[] function to implement (ii), but I think there must be another way)