2
LogLikelihood[MultinomialDistribution[100, {0.2, 0.3, 0.5}], {{10, 20, 70}}]

-12.8338

No problem at all.

n = 171
pj = {0.5678342897940185`, 0.05023062094430643`, 
  0.029299646238927373`, 0.023714945004969255`, 0.022954135971897396`,
   0.02636142850073763`, 0.04033297983450963`, 0.23927195371850615`}
Tr[pj] (* check probabilities sum to 1 *)
data = {3, 56, 19, 28, 18, 24, 14, 9}
Tr[data] (* check data points sum to n *)
LogLikelihood[MultinomialDistribution[n, pj], {data}]

Does not working as expected?

I have checked

data = RandomVariate[MultinomialDistribution[n, pj]]

MultinomialDistribution::vprobprm: "The value {0.567834,0.0502306,0.0292996,0.0237149,<<21>>,0.0263614,0.040333,0.239272} at position 2 in MultinomialDistribution[171,{0.567834,0.0502306,0.0292996,<<21>>,<<21>>,0.0263614,0.040333,0.239272}] is expected to be a list of numbers greater than or equal to 0 and summing to 1."

Why is this? I have checked that Tr[pj] is 1.

Win 7 MMA 10.0.2 X64enter image description here

Chen Stats Yu
  • 4,986
  • 2
  • 24
  • 50

2 Answers2

2

Normalize the coefficients:

pjj = Normalize[pj, Total];
data = {{3, 56, 19, 28, 18, 24, 14, 9}};
LogLikelihood[MultinomialDistribution[n, pjj], data]
(* -252.89 *)
Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
2

In general, it can be a useful first step in figuring out what's going on in these situations to check if your distribution is valid, using the DistributionParameterQ:

DistributionParameterQ@MultinomialDistribution[n, pj]

(*
MultinomialDistribution::vprobprm: The value {0.567834,0.0502306,0.0292996,0.0237149,0.0229541,0.0263614,0.040333,0.239272} at position 2 in MultinomialDistribution[171,{0.567834,0.0502306,0.0292996,0.0237149,0.0229541,0.0263614,0.040333,0.239272}] is expected to be a list of numbers greater than or equal to 0 and summing to 1. >>

False *)
Stefan R
  • 2,136
  • 18
  • 17