Message Boards Message Boards

Derivative of Gaussian likelihood function?

Posted 6 years ago

Consider the following code:

In[63]:= f[x_]=1/(2*Pi*sigma^2)^0.5Exp[-(x-mu)^2/(2*sigma^2)]
        In[64]:= p[x_]=Product[f[Subscript[x, i]],{i,1,n}]
        In[68]:= D[p[x],mu]

enter image description here

It simply did nothing but added a partial derivative symbol at the front of p(x). Am I missing something here?

POSTED BY: Jason Wu
5 Replies
Posted 6 years ago

@Daniel Lichtblau I think you are right, the D is not capable in rewriting the expression as a symbolic sum, we have to use log likelihood. It works very well for the sum of log

In[112]:= f[x_]=1/(2*Pi*sigma^2)^0.5Exp[-(x-mu)^2/(2*sigma^2)]
In[113]:= p[x_]=Sum[Log[f[Subscript[x, i]]],{i,1,n}]
In[114]:= D[p[x],mu]

enter image description here

POSTED BY: Jason Wu

Is the expectation is that this will be rewritten as a symbolic Sum, using the Leibniz formula for derivatives of products? If so, I do not think D is coded internally to do that with unevaluated symbolic products.

POSTED BY: Daniel Lichtblau

@FrankKampas, there is an argument count mismatch between p[x_, n_] and D[p[x], mu]

POSTED BY: Daniel Lichtblau
In[1]:= f[x_] = 1/(2*Pi*sigma^2)^0.5 Exp[-(x - mu)^2/(2*sigma^2)]

Out[1]= (0.398942 E^(-((-mu + x)^2/(2 sigma^2))))/(sigma^2)^0.5

In[4]:= p[x_, n_] = Product[f[Subscript[x, i]], {i, 1, n}];

In[5]:= D[p[x], mu]

Out[5]= 0
POSTED BY: Frank Kampas

that's what I get for posting this early in the morning

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract