Tricky RegionPlot Question (Mathematica)

I use the following to visualize a range of funds when averaging n coins as a function of n.

p is 1/2;
e is 1/4;
pp [n_, x_] = CDF [BinomialDistribution [n, p], x];
p3 = RegionPlot [pp [n, nx]> p - e && pp [n, nx] <p + e, {n, 1, 20}, {x, 0, 1}]

For aesthetic reasons, I want this graph to be contiguous, although this range does not make sense for non-integer n. The above solution gives the appearance of a “saw”, but instead I want it to look like a step ladder. So, for any non-integer n0, the area will be the same as for the largest integer n, not greater than n0, any idea how to do this?

+3
source share
1 answer

Assuming you want nintegers, try

p3 = RegionPlot[
        p - e < pp[nn, nn x] < p + e /. nn -> Floor[n],
        {n, 1, 20}, {x, 0, 1}
     ]
+3
source

Source: https://habr.com/ru/post/1759731/


All Articles