% belicitor.m

% Elicits a beta prior with the mean "mn" in (0,1)
% and with a "withprob" quantile equal to "quant".
% It solves a nonlinear equation involving betainc,
% since quantiles of beta are not explicit.

% given  E theta=0.8, P(theta < 0.9) = 0.95.
mn= 0.8  
quant = 0.9;
withprob = 0.95;



fun = @(alpha)  betainv(quant, alpha, alpha * (1 - mn)/mn )- withprob 
% 
  alph = fsolve( @(alpha)fun(alpha), 1)
  bet = alph  * (1 - mn)/mn
% 
% % alph = 6.5087
% % bet = 1.6272
% % The prior is (approx) B(6.5, 1.6).
% 
