# Plotting CDF but fluctuating graph

I'm trying to plot the following CDF: $$\sum^n_{k=1}{n-1\choose k-1}F(x)^{k-1}(1-F(x))^{n-k}\sum^n_{i=k}{n\choose i}G(y)^i(1-G(y))^{n-i}$$ at $x=1/2$, where $F(x)=x$ and $G(y)=y^2$. I try to plot it when $n=3,10,30,100$ to see the convergence, but the problem is that the graph is very nice when $n$ is smaller than $35$, but it fluctuates a lot if $n$ is greater than that.

The code I'm using is

ClearAll;

F[x_] = x;

G[y_] = y^2;

G1[y_, i_, n_] = Binomial[n, i]*G[y]^i*(1 - G[y])^(n - i);

G2[y_, k_, n_] = Sum[G1[y, i, n], {i, k, n}];

h[x_, y_, k_, n_] =   Binomial[n - 1, k - 1]*F[x]^(k - 1)*(1 - F[x])^(n - k)*G2[y, k, n];

h3[x_, y_] =   Assuming[Element[k, Integers] , Sum[h[x, y, k, 3], {k, 1, 3}]];

h10[x_, y_] =   Assuming[Element[k, Integers] , Sum[h[x, y, k, 10], {k, 1, 10}]];

h30[x_, y_] =   Assuming[Element[k, Integers] , Sum[h[x, y, k, 30], {k, 1, 30}]];

h40[x_, y_] =   Assuming[Element[k, Integers] , Sum[h[x, y, k, 40], {k, 1, 40}]];

Plot[{h3[1/2, y], h10[1/2, y], h30[1/2, y], h40[1/2, y]}, {y, 0, 1},
PlotLabels -> {"n=3", "n=10", "n=30", "n=40"}]


Analytically, the CDF is well defined. Can anyone tell what's wrong with the code?

• Have you already tried to set the option PlotPoints to higher values? See e.g. reference.wolfram.com/language/ref/PlotPoints.html Nov 8, 2017 at 16:29
• Try including WorkingPrecision->20 in your plot. Nov 8, 2017 at 16:35
• OMG WorkingPrecision totally works! Nov 8, 2017 at 16:37
• Hmm, it works for n=40, but does not for larger n.. Would there be any other way to plot them? Nov 8, 2017 at 17:07

Since BernsteinBasis[] is built-in, do this:
With[{x = 1/2}, 