calculate probability in MATLAB
THIS IS A MULTINOMIAL PROBABILITY DISTRIBUTION PROBLEM!
say we are given 4 outcome below along with the probabilities
Calculate the probability such that
my attempted code is
% Define the probabilities for each outcome
HH = 0.013;
HL = 0.267;
LH = 0.031;
LL = 0.689;
% Initialize the total probability
totalProbability = 0;
% Loop through possible counts for HL and LH
for nHL = 0:20
for nLH = 0:2
nHH = 0;
nLL = 100 – nHH – nHL – nLH
probability = mnpdf([nHH nHL nLH nLL], [HH HL LH LL])
totalProbability = totalProbability + probability;
end
end
% Display the result
disp([‘The total probability is: ‘, num2str(totalProbability)])
However the code gives the value 0.0056902 but the real answer is 0.00132705 so clearly something is wrong with my code.THIS IS A MULTINOMIAL PROBABILITY DISTRIBUTION PROBLEM!
say we are given 4 outcome below along with the probabilities
Calculate the probability such that
my attempted code is
% Define the probabilities for each outcome
HH = 0.013;
HL = 0.267;
LH = 0.031;
LL = 0.689;
% Initialize the total probability
totalProbability = 0;
% Loop through possible counts for HL and LH
for nHL = 0:20
for nLH = 0:2
nHH = 0;
nLL = 100 – nHH – nHL – nLH
probability = mnpdf([nHH nHL nLH nLL], [HH HL LH LL])
totalProbability = totalProbability + probability;
end
end
% Display the result
disp([‘The total probability is: ‘, num2str(totalProbability)])
However the code gives the value 0.0056902 but the real answer is 0.00132705 so clearly something is wrong with my code. THIS IS A MULTINOMIAL PROBABILITY DISTRIBUTION PROBLEM!
say we are given 4 outcome below along with the probabilities
Calculate the probability such that
my attempted code is
% Define the probabilities for each outcome
HH = 0.013;
HL = 0.267;
LH = 0.031;
LL = 0.689;
% Initialize the total probability
totalProbability = 0;
% Loop through possible counts for HL and LH
for nHL = 0:20
for nLH = 0:2
nHH = 0;
nLL = 100 – nHH – nHL – nLH
probability = mnpdf([nHH nHL nLH nLL], [HH HL LH LL])
totalProbability = totalProbability + probability;
end
end
% Display the result
disp([‘The total probability is: ‘, num2str(totalProbability)])
However the code gives the value 0.0056902 but the real answer is 0.00132705 so clearly something is wrong with my code. multinomial probability distribution MATLAB Answers — New Questions