# Using Inner to calculate a log likelihood

I am trying to use the function Inner to calculate the sum of log likelihoods of a custom probability distribution 'custom' applied to a vector of data 'vData'. The custom distribution changes structurally with each value of the data, meaning that each time I need a slightly adapted distribution. I do the following:

LogLikelihoodTotal[vData_,mu_]:=Inner[LogLikelihood,Custom[vData],vData,Plus]


And, as an example I get the following output, when I run the above function for a sample of data, and mu.

LogLikelihood[PoissonDistribution[26.244], 20] + LogLikelihood[PoissonDistribution[36.], 30]


The issue is that the LogLikelihood is not being evaluated because the latter input is expected to be a list, not just a value. I have tried making the data vector vData a List of Lists, by doing:

vData = Map[List,vData]


But I still can't get Mathematica to recognise the individual inputs of the data vector as lists.

Anyone have any idea how I can get round this issue?

For clarity, the data for each application of LogLikelihood is a single data value. So, what I would like my function to do is to return a number which is the evaluated version of:

LogLikelihood[PoissonDistribution[26.244], {20}] + LogLikelihood[PoissonDistribution[36.], {30}]


Thanks!

Ben

• Does Inner[LogLikelihood[#,{#2}]&,Custom[vData],vData] give what you need?
– kglr
Commented Feb 10, 2015 at 15:04
• Yes, it does! Thank you very much. Best, Ben Commented Feb 10, 2015 at 15:07

Inner[LogLikelihood[#,{#2}]&,Custom[vData],vData]