November 15 2002 8:18:37.171 AM BAYES_BETA Simple Bayesian Statistics demonstrations. BAYES_BETA Simple Bayesian Statistics demonstrations. Suppose we're watching a "system" and trying to analyze its behavior. Each time we observe the system, it flips a coin a certain number of times, and reports the number of heads and tails. We want to estimate THETA1 and THETA2, the probabilities of heads and of tails. We treat the values of THETA1 and THETA2 as random variables themselves, controlled by a Beta probability density function, which has parameters ALPHA1 and ALPHA2. We make an arbitrary or informed guess for initial values of ALPHA1 and ALPHA2. We observe the system, and adjust ALPHA1 and ALPHA2 using Bayes's Law. We continue until we are satisfied that our estimates seem to have converged. Run parameters: THETA1/THETA2: 0.750000 0.250000 Number of observations to make = 4 Number of tosses per observation = 5 Initial data: ALPHA1/ALPHA2 0.500000 0.500000 THETA1/THETA2: 0.500000 0.500000 Plot of Beta distribution, ALPHA1 = 0.5 ALPHA2 = 0.5 T BETA(T,ALPHA1,ALPHA2) 0.00000 0.00000 0.500000E-01 1.46051 0.100000 1.06103 0.150000 0.891446 0.200000 0.795775 0.250000 0.735105 0.300000 0.694609 0.350000 0.667359 0.400000 0.649747 0.450000 0.639827 0.500000 0.636620 0.550000 0.639827 0.600000 0.649747 0.650000 0.667359 0.700000 0.694609 0.750000 0.735105 0.800000 0.795775 0.850000 0.891446 0.900000 1.06103 0.950000 1.46051 1.00000 0.00000 BAYES_BETA - After observation 1 Prior observation data: Tosses: 0 Heads/Tails: 2*0 ALPHA1/ALPHA2: 0.500000 0.500000 THETA1/THETA2: 0.500000 0.500000 Observation data: Tosses: 5 Heads/Tails: 5, 0 Post observation data: Tosses: 5 Heads/Tails: 5, 0 ALPHA1/ALPHA2: 5.50000 0.500000 THETA1/THETA2: 0.916667 0.833333E-01 BAYES_BETA - After observation 2 Prior observation data: Tosses: 5 Heads/Tails: 5, 0 ALPHA1/ALPHA2: 5.50000 0.500000 THETA1/THETA2: 0.916667 0.833333E-01 Observation data: Tosses: 5 Heads/Tails: 4, 1 Post observation data: Tosses: 10 Heads/Tails: 9, 1 ALPHA1/ALPHA2: 9.50000 1.50000 THETA1/THETA2: 0.863636 0.136364 BAYES_BETA - After observation 3 Prior observation data: Tosses: 10 Heads/Tails: 9, 1 ALPHA1/ALPHA2: 9.50000 1.50000 THETA1/THETA2: 0.863636 0.136364 Observation data: Tosses: 5 Heads/Tails: 4, 1 Post observation data: Tosses: 15 Heads/Tails: 13, 2 ALPHA1/ALPHA2: 13.5000 2.50000 THETA1/THETA2: 0.843750 0.156250 BAYES_BETA - After observation 4 Prior observation data: Tosses: 15 Heads/Tails: 13, 2 ALPHA1/ALPHA2: 13.5000 2.50000 THETA1/THETA2: 0.843750 0.156250 Observation data: Tosses: 5 Heads/Tails: 3, 2 Post observation data: Tosses: 20 Heads/Tails: 16, 4 ALPHA1/ALPHA2: 16.5000 4.50000 THETA1/THETA2: 0.785714 0.214286 Plot of Beta distribution, ALPHA1 = 16.5 ALPHA2 = 4.5 T BETA(T,ALPHA1,ALPHA2) 0.00000 0.00000 0.500000E-01 0.229817E-15 0.100000 0.881377E-11 0.150000 0.386986E-08 0.200000 0.270454E-06 0.250000 0.685645E-05 0.300000 0.908944E-04 0.350000 0.764833E-03 0.400000 0.457904E-02 0.450000 0.209593E-01 0.500000 0.768679E-01 0.550000 0.232906 0.600000 0.594113 0.650000 1.28739 0.700000 2.36733 0.750000 3.64381 0.800000 4.53747 0.850000 4.24256 0.900000 2.48928 0.950000 0.508657 1.00000 0.00000 BAYES_BETA: Normal end of execution.