# Proof 1 k a z a b k a m thm 4 a b mod m 2 k c z c d k

• 14

This preview shows page 4 - 11 out of 14 pages.

Proof 1. k a Z , a = b + k a m ( Thm 4: a b (mod m ) ) 2. k c Z , c = d + k c m ( Thm 4: c d (mod m ) ) 3. a – c = b – d + (k a – k c )m ( 1. – 2. ) 4. a – c ≡ b – d ( mod m ) ( 3. & Thm 4 )
Copyright © Peter Cappello 2013 5 Generating Pseudo-random Numbers Generating pseudo-random numbers has important applications. One application area is the Monte Carlo Method . Wikipedia MathWorld We glimpse 2 Monte Carlo Method applications crucial to the survival of the human species . Approximate π Approximate winning probabilities in Texas Hold’em
Copyright © Peter Cappello 2013 6 Approximate π Via the Monte Carlo Method (throwing darts) 1 1 1/2 A CIRCLE = π r 2 = π / 4 A SQUARE = 1 A CIRCLE ---------- = π / 4 A SQUARE
Copyright © Peter Cappello 2013 7 (0, 0 ) ( x, y ) If ( x 2 + y 2 <= 1/4 ) then (x, y) is “in” circle. ½ (- ½ , - ½ ) (½ , ½ )
Copyright © Peter Cappello 2011 8 Use the Monte Carlo Method Approximate π : via the Monte Carlo method: double approximatePi( int n ) { int inCircle = 0; for ( int i = 0; i < n; i++ ) { double x = rand( 0, 1 ); double y = rand( 0, 1 ); if ( isInCircle( x – 0.5, y – 0.5 ) ) inCircle++; } return 4.0 * inCircle / (double ) n; // double operands }
Copyright © Peter Cappello 2011 9 boolean inCircle( double x, double y ) boolean isInCircle( double x, double y ) { return ( x*x + y*y <= 0.25 ) ? true : false; }
Copyright © Peter Cappello 2011 10 Texas Hold 'em The “ probabilities” they give that a player will win the hand are approximate . They use the Monte Carlo method: n times: Randomly guess 5 community cards. For each guess, compute the winner .
• • • 