From number of heads/tails, how can I find the probability distribution? Knowing the number of heads/tails for a given number of tosses of a coin, how can I find the probability distribution? That is, how can I find the probability that the coin is balanced, or that the coin has 70/30 unbalance and so on?
Thank you :)
João
 A: A possible approach could be a maximum likelihood method:


*

*You have got a sample with size $n$ with $h$ heads and $t = n-h$ tails.

*Let $X$ be the random variable for the number of heads.

*You know that $X$ follows a binomial distribution with parameters $n$ and $p$, where $n$ is the sample size and $p$ is the unkown probability of getting a head.

*Now, choose $p$ such that the sample has maximum likelihood:
$$P(X = h) = \binom n h p^h(1-p)^{n-h} = \binom n h p^h(1-p)^t \stackrel{!}{\rightarrow} \mbox{Max}$$
A: I've read about likelihood functions for some time now, but never actually used it.  My "solution" below is actually just a Matlab/Octave implementation of trancelocation's answer to this same question.  It was to dip my foot into the "likelihood" knowledge pool.
N=20;  % Sample size
h=15;  % Number of heads

% Possible values for probability of success 
p = 0 : 0.05 : 1.00;

if logical(exist('OCTAVE_VERSION', 'builtin')) % If running Octave
  pkg load statistics % Package must downloaded beforehand!
end %  if

% Calculate likelihood by using binomial
% distribution at each value of p

if true % false yields same, but likelihood is more explicit

  L_p = binopdf( h, N, p ); % Efficient one-liner

else

   % More explicitly shows likelihood rather than probability
   for i_p = 1 : length(p)
     L_p(i_p) = binopdf( h, N, p(i_p) );
   end % for i_p

end % if

% Plot likelihood function
plot( p, L_p, 'o' , 'MarkerFaceColor' , 'b' );
set(gca,'XTick' , 0:0.1:1 );
grid on
xlabel(sprintf( "Probability p of getting heads", p ));
ylabel(sprintf( "Likelihood of p,\ngiven %g head in %G flips", h, N ));


