John Travis
Mississippi College
MATH 353 - Introduction to Mathematical Probability and Statistics
Textbook: Tanis and Hogg, A Brief Course in Mathematical Statistics
Conditional vs independent events
{{{id=1| %auto var('Ace Clubs Diamonds Hearts Jack King Queen Spades') suits = [Spades, Diamonds, Clubs, Hearts] values = [2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace] deck = [(value, suit) for suit in suits for value in values] full_deck = copy(deck) # to save a copy of the original deck for later use. pretty_print(html('Consider the full standard deck of 52 cards as a collection of ordered pairs (face,suit)')) for value in values: show([(value,suit) for suit in suits]) /// Consider the full standard deck of 52 cards as a collection of ordered pairs (face,suit) }}}Let's consider the difference between picking two cards with replacement vs picking two cards without replacement.
{{{id=12| %auto print "Conditional Events - successively deal 5 cards w/o replacement" deck1 = copy(full_deck) history1=[] @interact def _(choice=['Hearts','Spades','Diamonds','Clubs','New Deck']): global deck1, history1 shuffle(deck1) if choice=='Hearts': suit = Hearts elif choice=='Spades': suit = Spades elif choice=='Diamonds': suit = Diamonds elif choice=='Clubs': suit = Clubs else: deck1 = copy(full_deck) shuffle(deck1) history1=[] if (Set(deck1).cardinality()<5): pretty_print('Deck is too small...get a new deck') elif choice<>'New Deck': hand = [deck1.pop() for card in range(5)] print "Click on a desired suit above to deal out another 5 card hand. The cards dealt:" show(hand) print "The remaining cards in the deck:" print deck1 num = Set(deck1).cardinality() pretty_print("\nThe number of remaining cards in the deck = %s"%str(num)) looking = [] for card in deck1: if card[1]==suit: looking.append(card) prob = float(Set(looking).cardinality())/num history1.append(prob) pretty_print('So, the remaining probability of getting a card from '+choice+' from the remaining cards is %s'%str(prob)) list_plot(history1).show(xmin=0,xmax=9,ymin=0,ymax=1,figsize=(5,2)) /// Conditional Events - successively deal 5 cards w/o replacement
|
Notice that the probability changes of getting a card from a given suit changes as progressive hands are dealt if the cards are not replaced before redealing.
{{{id=10| %auto print "Independent Events - Successively deal 5 cards but WITH replacement" #deck1 = copy(full_deck) history2=[] @interact def _(choice=['Heart','Spade','Diamond','Club']): if choice=='Hearts': suit = Hearts elif choice=='Spades': suit = Spades elif choice=='Diamonds': suit = Diamonds else: suit = Clubs deck1 = copy(full_deck) shuffle(deck1) hand = [deck1.pop() for card in range(5)] print "The cards dealt:" show(hand) print "Replacing this hand and reshuffling gives the remaining cards in the deck:" deck1 = copy(full_deck) shuffle(deck1) print(deck1) num = Set(deck1).cardinality() pretty_print("\nThe number of remaining cards in the deck = %s"%str(num)) looking = [] for card in deck1: if card[1]==suit: looking.append(card) prob = float(Set(looking).cardinality())/num history2.append(prob) pretty_print('So, the remaining probability of getting a '+choice+' from the remaining cards is %s'%str(prob)) list_plot(history2).show(xmin=0,xmax=9,ymin=0,ymax=1,figsize=(5,2)) /// Independent Events - Successively deal 5 cards but WITH replacement
|
The stuff below is just playing around with sampling. Don't bother with this right now.
Events are independent provided the occurance of a first event does not likelihood of a subsequent event.
Create an interact which picks random integers from 1 to 10 and then picks another random number from 1 to 10.
Two cases: