import pymc as pms = (3,4)x = pm.Normal('x', mu = 1.5, tau = 1.0, size = s)y = pm.Normal('y', mu = x, tau = 1.0)#pymc comes with many ways of creating deterministics, including many numpy-like factory-functions (sin, exp, log, sum etc.)# as well as numpy-like indexing and operatorsa = pm.exp(y)b = pm.sum(a, axis = None)c = a + bd = a[:, 0]z = pm.Normal('z', mu = b, tau = 1.0, value = 1.0, observed = True)# to calculate the gradient of the log likelihood useprint pm.logp_gradient_of_set(set((x,y)))# it returns a dictionary with the gradients for each of the variables with respect to the whole system# you can also restrict the calculation to a subset ofrestricted_set = set((x,y))print pm.logp_gradient_of_set(set((x,y)), restricted_set) #won't include the loglikelihood of z in the calculation
This is an impressive piece of work.
David
> --
> You received this message because you are subscribed to the Google Groups
> "PyMC" group.
> To post to this group, send email to py...@googlegroups.com.
> To unsubscribe from this group, send email to
> pymc+uns...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pymc?hl=en.
>