I use the following to visualize the range of means when averaging n coin tosses as a function of n.
p = 1/2;
e = 1/4;
pp[n_, x_] = CDF[BinomialDistribution[n, p], x];
p3 = RegionPlot[pp[n, n x] > p - e && pp[n, n x] < p + e, {n, 1, 20}, {x, 0, 1}]
For aesthetic reasons, I want that plot to be contiguous even though this range doesn't make sense for non-integer n. The solution above gives a "saw-tooth" appearance, but instead I want it to look like a step ladder, So, for any non-integer n0 the region would be the same as for the largest integer n not greater than n0, any idea how to accomplish this?
Assuming you want n to be integers, try
p3 = RegionPlot[
p - e < pp[nn, nn x] < p + e /. nn -> Floor[n],
{n, 1, 20}, {x, 0, 1}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With