353 - Topic 03 - Conditional/Independent

704 days ago by Professor353

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

       
Consider the full standard deck of 52 cards as a collection of ordered pairs (face,suit)

                                
                            
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.

       

Conditional Events - successively deal 5 cards w/o replacement

choice 

Click to the left again to hide and once more to show the dynamic interactive window

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.

%hide %auto print html('<font size=+2 color=green><p>Independent Events - Successively deal 5 cards but WITH replacement</font>') #deck1 = copy(full_deck) history2=[] @interact def _(choice=['Heart','Spade','Diamond','Club']): if choice=='Hearts': suit = H elif choice=='Spades': suit = S elif choice=='Diamonds': suit = D else: suit = C deck1 = copy(full_deck) shuffle(deck1) hand = [deck1.pop() for card in range(5)] print html("<p><p>The cards dealt:") show(hand) print html("Replacing this hand and reshuffling gives the remaining cards in the deck:") deck1 = copy(full_deck) shuffle(deck1) print(deck1) num = Set(deck1).cardinality() print(html("\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) html('So, the remaining probability of getting a '+choice+' from the remaining cards is <font size=+2 color=red>%s</font>'%str(prob)) list_plot(history2).show(xmin=0,xmax=9,ymin=0,ymax=1,figsize=(5,1)) 
       

Click to the left again to hide and once more to show the dynamic interactive window

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: 

  • the first selection is removed and the second selection can come from only the remaining integers
  • the first selection is recorded and then "replaced" so that the second selection can come from any of the original integers
@interact def _(n = slider(10,1000,30,10,label='Number of samples')): Samples = range(n) max_pt=20 Domain = range(max_pt) A = [ZZ(int(max_pt*(random()))) for i in Samples] F = frequency_distribution(A) points((x,F(x)) for x in Domain).show(ymin=0) 
       

Click to the left again to hide and once more to show the dynamic interactive window

low = 0 high = 10 @interact def _(n=slider(1,100,1,label='Number of Trials'),replace=checkbox(false,label='With replacement?')): A = random_matrix(ZZ, 1, n, x=1, y=high+1) A1= zero_matrix(1,high) print A1 for k in range(1,high+1): print 'hi' # A1(A(k)) += 1 print A1 R = [low..high] A = IndexedSequence(A,R) G=A.plot_histogram(eps=0.5,clr='green') show(G,ymin=0) 
       

Click to the left again to hide and once more to show the dynamic interactive window