two_p_update.RdComputes posterior distribution of two proportions with a discrete prior
two_p_update(prior, s1f1, s2f2)
| prior | prior probability matrix where the rows and columns are labeled with the values of the proportions |
|---|---|
| s1f1 | number of successes and number of failures from first sample |
| s2f2 | number of successes and number of failures from second sample |
posterior probability matrix
prior <- testing_prior() first_sample <- c(3, 10) second_sample <- c(8, 20) two_p_update(prior, first_sample, second_sample)#> 0.1 0.2 0.3 0.4 0.5 #> 0.1 4.208081e-03 1.276979e-02 2.265034e-02 1.036690e-02 1.611774e-03 #> 0.2 1.295862e-03 2.516740e-01 5.580069e-02 2.553957e-02 3.970716e-03 #> 0.3 1.150570e-03 2.793205e-02 3.963546e-01 2.267608e-02 3.525520e-03 #> 0.4 5.837966e-04 1.417265e-02 2.513866e-02 9.204629e-02 1.788840e-03 #> 0.5 1.841531e-04 4.470629e-03 7.929755e-03 3.629392e-03 4.514182e-03 #> 0.6 3.416825e-05 8.294921e-04 1.471307e-03 6.734068e-04 1.046966e-04 #> 0.7 3.055454e-06 7.417631e-05 1.315698e-04 6.021857e-05 9.362367e-06 #> 0.8 7.909317e-08 1.920121e-06 3.405804e-06 1.558812e-06 2.423533e-07 #> 0.9 1.099757e-10 2.669845e-09 4.735624e-09 2.167461e-09 3.369819e-10 #> 0.6 0.7 0.8 0.9 #> 0.1 7.990129e-05 8.696678e-07 7.611386e-10 1.862447e-15 #> 0.2 1.968424e-04 2.142487e-06 1.875118e-09 4.588268e-15 #> 0.3 1.747724e-04 1.902271e-06 1.664880e-09 4.073832e-15 #> 0.4 8.867908e-05 9.652077e-07 8.447557e-10 2.067052e-15 #> 0.5 2.797298e-05 3.044657e-07 2.664703e-10 6.520321e-16 #> 0.6 4.152143e-05 5.649135e-08 4.944158e-11 1.209797e-16 #> 0.7 4.641254e-07 4.041336e-08 4.421253e-12 1.081846e-17 #> 0.8 1.201430e-08 1.307670e-10 9.155848e-13 2.800457e-19 #> 0.9 1.670537e-11 1.818259e-13 1.591352e-16 3.115132e-21