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

Condorcet jury theorem formula

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


Then I try to plot it:


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.

  • $\begingroup$ Do not use "N". use "n" instead $\endgroup$ – J42161217 Dec 22 '18 at 16:43
  • $\begingroup$ thanks I changed it to "n". but the plot is still empty $\endgroup$ – DBR Dec 22 '18 at 16:45
  • $\begingroup$ Try ListPlot[Flatten@B] $\endgroup$ – J42161217 Dec 22 '18 at 16:51
  • $\begingroup$ 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}]]. $\endgroup$ – JimB Dec 22 '18 at 16:57
  • $\begingroup$ This works. thank you both $\endgroup$ – 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

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}]

Mathematica graphics

Use Manipulate to explore the function as p and n varies.

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

enter image description here

Hope this helps.


Not the answer you're looking for? Browse other questions tagged or ask your own question.