Jupyter notebook Coin_Flipping.ipynb
Two initialization blocks.
This file is interactive when loaded into an ipython/jupyter Notebook. Note to self: Don't forget to rewrite it as interactive web "Trinket," and as an Rmarkdown document.
Here's code creating a function that flips a fair coin.
Just execute the function to flip the coin.
Here's code creating a function that flips a fair coin however many times you specify, and then reports the total number of heads followed by the total number of tails.
Just execute the function (specifying the number of flips) to see the result.
Here's code creating a function that flips a fair coin however many times you specify, and then reports the total number of time heads was "winning" followed by the total number of tails was "winning" followed by the total number of times they were tied.
Just execute the function (specifying the number of flips) to see the result.
More interesting (to me) than the result from any individual run of coin flipping, would be to find some way to compare this "winners & ties" result to what might be a typical result. Unfortunately, I have neither instinct nor intuition as to what typical might be in this case.
So...it might be worthwhile to repeat the flipping & tallying and create distributions for winners and ties.
Here's code creating a function that repeats flipping a fair coin however many times you specify, and then tallies the total number of time heads was "won" tallies the total number of times tails "won" and tallies the total number of times they were tied.
###Just execute the function (specifying the number of repetitions followed by the number of flips in each run) to construct the three distributions.
###A histogram is probably the best way to look at these distributions. Here's the one for heads:
###Here's the distrbution for tails:
###And here's the distrbution for ties:
###Maybe these distributions aren't the best perspective. Let's try looking at things from the perspective of the final winner. And for the moment restrict howmany to odd to force a final winner.
##Please send any comments or corrections to: [email protected]