%%

disttool %Open window with distribution tool 

%% Kaffi, te eller sjokolade?, multinomisk fordeling
% Compute the distribution
p = [0.5,0.3,0.2]; % Outcome probabilities
n = 20; % Sample size
x1 = 0:n;
x2 = 0:n;
[X1,X2] = meshgrid(x1,x2);
X3 = n-(X1+X2);
Y = mnpdf([X1(:),X2(:),X3(:)],repmat(p,(n+1)^2,1));

% Plot the distribution
Y = reshape(Y,n+1,n+1);
bar3(Y)
xlabel('Kaffi')
ylabel('Te')
zlabel('Probability Mass')
title('Trinomial fordeling')

%%
mnpdf([10,7,3],p) %multinomial pdf 



