Hello. I need help with understanding matlab algorithm with beta and gamma distribution.
1) Algorithm with Beta distibution (MATLAB):
function [expected, phat]=bayes_beta_beta(prior_proportions,successes,trials)
phat=betafit(prior_proportions);
alpha = phat(1);
beta = phat(2);
expected=(successes+alpha)./(trials+beta+alpha);
end
My question - how did we get expected value this way? In Wikipedia expected value of Beta distribution - alpha/(alpha+beta).
2) Algorithm with Gamma distibution (MATLAB):
function [expected, phat]=bayes_gamma_expo(prior_data,sample,valid_n)
phat=gamfit(prior_data);
alpha = phat(1);
beta = phat(2);
expected=1./((alpha+valid_n)./(1/beta+sample));
end
My question is same - how did we get this strange formula for expected values? Sorry if my questions is silly. I'll be glad to any materials or tips about my questions.
1) Algorithm with Beta distibution (MATLAB):
function [expected, phat]=bayes_beta_beta(prior_proportions,successes,trials)
phat=betafit(prior_proportions);
alpha = phat(1);
beta = phat(2);
expected=(successes+alpha)./(trials+beta+alpha);
end
My question - how did we get expected value this way? In Wikipedia expected value of Beta distribution - alpha/(alpha+beta).
2) Algorithm with Gamma distibution (MATLAB):
function [expected, phat]=bayes_gamma_expo(prior_data,sample,valid_n)
phat=gamfit(prior_data);
alpha = phat(1);
beta = phat(2);
expected=1./((alpha+valid_n)./(1/beta+sample));
end
My question is same - how did we get this strange formula for expected values? Sorry if my questions is silly. I'll be glad to any materials or tips about my questions.