Saturday, September 9, 2023

Casio fx-9750GIII: Coin Flips and Probability of Winning

Casio fx-9750GIII:  Coin Flips and Probability of Winning




Introduction


The program COINPROB answers two questions in probability:



Take a game, with the chance of winning p.    There are only wins (success) and losses (failures).  Each game is independent and has the same chance of win.


1.  What is the chance of having an amount of wins in a set amount of games?   The binomial distribution is used to answer this question.


2. How many losses must be endured before a win occurs?  For this question, we turn to the geometric distribution.


Three results are listed are:


PDF:  the probability

MEAN:  expected value

VAR:  variance


The probability of success is also listed.



Casio fx-9750GIII Program:  COINPROB


Program Code:

(most spaces are added for readability)


"EWS 2023-06-25"

.5 → P

Locate 1, 4, "P(WIN) = P"

Locate 1, 5, "P(LOSS) = 1-P"

Locate 1, 6, "GAMES = TRIALS" ◢


Lbl 0

ClrText

Menu "PROB WIN VS LOSS", "SETTINGS", S, "# WINS IN GAMES", 1,

"# LOSS BEF. WIN", 2, "EXIT", E


Lbl S

Menu "SETTINGS", "P(WIN) = 0.5", F, "SET P(WIN)", U

Lbl F

.5 → F

"P(WIN) = .5"

"P(LOSS) = .5" ◢

Goto 0


Lbl U

"P(WIN)"? → P

"P(LOSS) = "

1 - P ◢

Goto 0


Lbl 1

"# GAMES"? → N

"# WINS"? → S

N nCr S × P^S × (1 - P)^(N - S) → D

N × P → M

M × (1 - P) → V

Goto R


Lbl 2

"# LOSSES"? → F

(1 - P)^(F - 1) × P → D

P⁻¹ → M

M × (1 - P) ÷ P → V

Goto R


Lbl R

ClrText

Locate 1, 3, "PDF= "

Locate 7, 3, D

Locate 1, 4, "MEAN="

Locate 7, 4, M

Locate 1, 5, "VAR="

Locate 7, 5, V

Locate 1, 6, "P(WIN)="

Locate 9, 6, P ◢

Goto 0


Lbl E

"THANK YOU"


Note:  The bold C is the combination function (nCr).  


A typo has been corrected (see line in red).  I thank Richard Antley for pointing out my error. - 9/27/2023 


Examples



1.  A fair coin is flipped.  You win if the coin flipped is heads.   What is the probability that you win 7 out of 10 times?


P = 0.5


# GAMES?  10

# WINS?  7


Problem Type:  # WINS IN GAMES


Results:

PDF=  0.1171875

MEAN= 5

VAR= 2.5

P(WIN)= 0.5


2.  What is the probability that you flip 7 tails before flipping a head?  Assume a fair coin.


P = 0.5


Problem Type:  # LOSS BEF. WIN


# LOSSES? 7


Results:


PDF=  0.0078125

MEAN= 2

VAR= 2

P(WIN)= 0.5


3.  On any given day in Luau Town, the chance of rain is 35% each day.   On a given week, how many days are expected to be sunny?


WIN:  sunny days (because that is what we want)

P(WIN) = 1 - 35% = 65% = 0.65

We want the mean (expected value).


Problem Type:  # WINS IN GAMES


Change P(WIN) to 0.65 in settings.  


# GAMES?  7  (7 days)

# WINS? (since we are interested in the mean, we can enter any number 0 to 7)


Results:


PDF= (N/A)

MEAN= 4.55

VAR= 1.5925

P(WIN)= 0.65


A week is expected to have about 4.55 sunny days.  Expected value does not have to be an integer.


4.  Assuming the chance of rain is 35% in Luau Town, what is the chance that there are 3 rainy days before a sunny day?


WIN:  sunny days, P(WIN) = 0.65


# LOSSES?  3


Results:  


PDF= 0.079625

MEAN= 1.538461538

VAR= 0.8284023669

P(WIN)= 0.65



Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

  Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...