1
$\begingroup$

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

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

1 Answer 1

1
$\begingroup$

As per the answer from kguler - the following works:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.