Function Repository Resource:

IdealCoinTossStatistics

Source Notebook

Compute the probabilities and statistics associated with tossing a coin

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["IdealCoinTossStatistics"][n]

computes probabilities and statistics associated with tossing n fair coins.

ResourceFunction["IdealCoinTossStatistics"][n,h]

computes probabilities and statistics associated with tossing n fair coins, of which h are heads.

ResourceFunction["IdealCoinTossStatistics"][{n,w}]

computes probabilities and statistics associated with tossing n coins having a probability of heads w.

ResourceFunction["IdealCoinTossStatistics"][{n,w},h]

computes probabilities and statistics associated with tossing n coins, of which h are heads.

ResourceFunction["IdealCoinTossStatistics"][,prop]

returns property prop for the coin toss.

Details and Options

ResourceFunction["IdealCoinTossStatistics"] returns an Association of properties with a subset of the following keys, depending on the input form:
Alldefault method that returns probabilities and statistics associated with tossing coins
"ProbabilityAllHeads"probability that all coins tossed display heads
"ProbabilityAllTails"probability that all coins tossed display tails
"ProbabilityHalfHeads"probability that Floor[n/2] tossed coins display heads
"ProbabilityAtLeastOneHeads"probability that at least one tossed coin displays heads
"ProbabilityAtLeastOneTails"probability that at least one tossed coin displays tails
"ProbabilitySetNumberHeads"formula for the probability of tossing a given number of heads
"ExpectedNumberHeads"expected value of the number of heads
"PDFPlot"plot of the normal approximation probability density function
"CDFPlot"plot of the normal approximation cumulative density function
"PercentHeadspercent heads in the given number of coin tosses
"PercentTails"percent tails in the given number of coin tosses
"ProbabilityGivenOrFewerHeads"probability that the number of heads displayed is at most the given number
"ProbabilityMoreThanGivenHeads"probability that the number of heads displayed is more than the given number
"ProbabilityGivenOrMoreHeads"probability that the number of heads displayed is at least the given number
"ProbabilityFewerThanGivenHeads"probability that the number of heads displayed is fewer than the given number
For n>9, the "SampleSpace" property in the association is suppressed due to size.

Examples

Basic Examples (2) 

Compute the probability and associated statistics of tossing 5 fair coins:

In[1]:=
ResourceFunction["IdealCoinTossStatistics"][5]
Out[1]=

Compute the probability and associated statistics of tossing 5 unfair coins:

In[2]:=
ResourceFunction["IdealCoinTossStatistics"][{5, 1/3}]
Out[2]=

Return only the probability density function plot:

In[3]:=
ResourceFunction["IdealCoinTossStatistics"][{5, 1/3}, "PDFPlot"]
Out[3]=

Scope (1) 

Compute the probability and associated statistics of tossing 5 unfair coins, of which 3 are heads:

In[4]:=
ResourceFunction["IdealCoinTossStatistics"][{5, 1/3}, 3]
Out[4]=

Properties and Relations (1) 

To simulate a coin toss, use CoinTossSimulator:

In[5]:=
ResourceFunction[
ResourceObject[
Association[
   "Name" -> "CoinTossSimulator", "ShortName" -> "CoinTossSimulator", "UUID" -> "b0623afa-5770-4052-911b-3b7e673f3785", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Dynamically simulate tossing a coin", "RepositoryLocation" -> URL[
     "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\
8bc106e9f84146af850469649707c11f`CoinTossSimulator", "FunctionLocation" -> CloudObject[
     "https://www.wolframcloud.com/obj/ad920446-e120-4915-8d3e-\
39db72fb32b1"]], ResourceSystemBase -> Automatic]][]
Out[5]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 2.0.0 – 23 March 2023
  • 1.0.0 – 18 September 2020

Related Resources

Author Notes

To view the full source code for IdealCoinTossStatistics, run the following code:

License Information