> this is an awesome example. is there an easy way (as in non-brute force) to finding the beta parameters that'll match a probability?
> this is an awesome example. is there an easy way (as in non-brute force) to finding the beta parameters that'll match a probability?
from scipy.stats import beta
import numpy as np
def betamax(params0, params1, integration_points=5000):
u0 = params0[0] / sum(params0)
u1 = params1[0] / sum(params1)
flip = u0 < u1
if flip:
params0, params1 = params1, params0
q = beta(*params0).ppf(np.linspace(0, 1, integration_points + 2)[1:-1])
c = beta(*params1).cdf(q)
p = c.mean()
if flip:
return 1 - p
return p >>> betamax((3, 14), (4, 12))
0.29448379324802676
>>> betamaxinv(0.29, allowed_error=0.01)
[((3, 14), (4, 12)), ...]
I assume the results of `betamaxinv` are not unique, and so perhaps there need to be constraints, or return a family of results. I don't know. I'm trying to wrap my head around how OP got A ~ Beta(2,13) and B ~ Beta(3,11) without just brute forcing numbers into `betamax`.He also explains that easy analytical solutions often don't exists to seemingly easy questions, such as this one. That's why Bayesian statistics needs Monte-Carlo.
What I'm asking is: how do you find parameters for A and B given "P(B > A) = 0.71"?
About the actual question, I don't think that's very well specified in this form. You could have A~Beta0 where Beta0 is very concentrated around let's say 0.5, and then find a B~Beta1 where Beta1 has 71% of its weight above 0.5. That would be a pretty good approximation for it, in fact as close as you want if you increase sample size of A. I can't verify this, but I think finding Beta1 should be easy. Obv this is not what you are looking for though, because this would require A to have a much larger sample size than B. I guess we should add some restriction, like similar sample sizes.
It makes sense, I'm just surprised the blog never comes out and says "you have to do a brute force search to get the parameters for the likelihoods A ~ Beta(2,13) and B ~ Beta(3,11) for P(B > A) to have about the right value".
Further what do you mean by
> “ the blog never comes out and says "you have to do a brute force search to get the parameters for the likelihoods A ~ Beta(2,13) and B ~ Beta(3,11) for P(B > A) to have about the right value".”
What do you mean by “brute force search” here?