Definition
Definition
In[]:=
BidenFraction[Association["Trump"t_,"Biden"b_],f_,margin_:0]:=BidenFraction[{{t,b},f},margin]
In[]:=
BidenFraction[{v:{t_,b_},f_},margin_:0]:=Module[{cast=Total[v],ultimate,remaining},ultimate=cast/f;remaining=ultimate-cast;Reduce[t+(1-bf)remaining+margin*ultimate<b+bf*remaining,bf][[2]]]
Documentation
Documentation
In[]:=
Usage
Usage
BidenFraction[a,f]
takes an in which the keys are "Trump" and "Biden" and the values are the number of votes they have and f, which is the fraction of ultimate votes already believed to have been case.
Association
a
BidenFraction[a,f,m]
performs similarly but requires Biden to win by fraction of the ultimate votes cast.
a
m
In[]:=
Details & Options
Details & Options
◼
By default, the optional argument is set to zero; Biden is just required to win by one vote.
m
◼
The Trump fraction, the fraction of uncounted votes Donald Trump needs to have a majority in a state is simply one minus the Biden fraction.
Examples
Examples
In[]:=
Basic Examples
Basic Examples
Compute the fraction of remaining votes in Georgia that Biden would need to win given the data on the CNN website at :
In[]:=
BidenFraction["Trump"2439800,"Biden"2430265,0.98]
Out[]=
0.547968
Compute the fraction of remaining votes in Pennsylvania that Biden would need to win the state by a 1% margin (using data on the CNN website at ) and silence the error:
In[]:=
Quiet@BidenFraction["Trump"3247808,"Biden"3157266,0.93,0.01]
Out[]=
0.665332
In[]:=
Applications
Applications
The estimates for the number of votes cast could be incorrect. Plot the fraction of remaining votes Biden needs to win in Pennsylvania by 0% and by 1% given varying estimates as the fraction of votes already cast:
In[]:=
Legended[Apply[Show][Table[Plot[Quiet@BidenFraction["Trump"3247808,"Biden"3157266,cast,(m-1)*.005],{cast,0.85,0.99},AxesFalse,FrameTrue,FrameLabel{"fraction of votes already cast","Biden fraction"},PlotStyleColorData[98][m]],{m,1,5}]],LineLegend[ColorData[98][#]&/@Range[5],Range[0,0.025,0.005],LegendLabel"Biden victory margin"]]
Out[]=
Code for BidenVictory FormPage
Code for BidenVictory FormPage
fp=FormPage{{"Trump","Trump votes so far"}Number,{"Biden","Biden votes so far"}Number,{"Fraction Cast","Fraction of ultimate votes already cast\n(enter as a decimal like 0.93)"}Restricted["Number",{0,1}],{"Margin","Percentage of Biden victory you require\n(enter as a decimal like 0.005; default is 0)"}Number0},If[#Margin0,StringTemplate["Joe Biden will win if he obtains at least `1` of the votes remaining to be cast"],StringTemplate["Joe Biden will win by a margin of at least `2` if he obtains at least `1` of the votes remaining to be cast"]]RoundQuiet@[Association["Trump"#Trump,"Biden"#Biden],#"Fraction Cast",#Margin],0.0001,#Margin&,PageTheme"Blue",AppearanceRulesAssociation["Title""What fraction of uncounted votes does Biden need?","Description""By Seth J. Chandler"]
Out[]=
In[]:=
CloudDeploy[fp,"BidenVictoryCalculator"]
