function x = loadedCoin(w,n)
% Returns a vector x of n random bits (zero or one)
% Input
%   w : weight (probability) of heads result (x=1)
%   n : number of values to be returned
% Output
%   x : row vector of n random bits (zero or one)
% Usage
%   x = coin(100)
% Author
%   Jose M Soler. Nov.2010

% rand(1,n) returns random numbers between 0 and 1
% rand<w returns 1 if rand is smaller than w, and 0 otherwise

x = (rand(1,n) < w);

end