# Plotting the condorcet jury theorem [closed]

I am trying to create a simple plot of the condorcet jury theorem: The function is:

F[n_,i_,p_]:=((n!)/((n-i)!*i!))*((p^i) *(1-p)^(n-i))


embedded in a sum from i to n:

P[n_,i_]:=Sum[  F,{i,n}]


Then I create a Table with all the values for N=1-100, and p=0.1-0.9

B=Table[F[n,i,p],{n,1,100,10},{i,1},{p,0.1,0.9,0.1}]


Then I try to plot it:

ListPlot[B]


but the plot is empty.

What am I missing?

## closed as off-topic by Bob Hanlon, Daniel Lichtblau, m_goldberg, bbgodfrey, Αλέξανδρος ΖεγγDec 25 '18 at 5:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, Daniel Lichtblau, m_goldberg, bbgodfrey, Αλέξανδρος Ζεγγ
If this question can be reworded to fit the rules in the help center, please edit the question.

• Do not use "N". use "n" instead – J42161217 Dec 22 '18 at 16:43
• thanks I changed it to "n". but the plot is still empty – DBR Dec 22 '18 at 16:45
• Try ListPlot[Flatten@B] – J42161217 Dec 22 '18 at 16:51
• Please describe what the desired plot should look like. Do you want a plot of p vs. F for each value of n? (And I don't see why P[n_,i_]:=Sum[ F,{i,n}] is included in the question.) In any event you'll need to follow @J42161217 's advice with the use of Flatten. Take a look at B and see that it isn't in the form that ListPlot expects. Maybe: B = Flatten[ Table[{p, F[n, i, p]}, {n, 1, 100, 10}, {i, 1}, {p, 0.1, 0.9, 0.1}], 1]; ListPlot[B, Joined -> True, PlotLegends -> Table[n, {n, 1, 100, 10}]]. – JimB Dec 22 '18 at 16:57
• This works. thank you both – DBR Dec 22 '18 at 17:01

You may use DiscretePlot. Note that your functions should not begin with capital letters unless in a package.

With F as defined in OP and

ClearAll[P]
P[n_Integer, p_] := Sum[F[n, i, p], {i, n}]


Then for some p, say 0.3, and some n, say 20, then

DiscretePlot[P[n, .3], {n, 20}] Use Manipulate to explore the function as p and n varies.

Manipulate[
DiscretePlot[P[n, p], {n, bigN}],
{{p, 0.2}, .01, 1., .01},
{{bigN, 20, "N"}, 1, 100, 1}
] Hope this helps.