Hi Chris,
Thank you very much, this is fantastic. Your help is much appreciated,
the computation time is now very similar to that under BUGS. I am
pleased to say that i had made some progress towards a similar
solution, but was using decorator classes and could not quite get the
right inputs for the @stochastic variable.
I did have to make one change to the code you sent - i had to coerce N
[:-1] to an array before it would execute in the line
Er = Lambda("Eri", lambda N=array(N[:-1]), ev=ev, rm=rm, K=K: exp(rm *
(1 - (N/K)) + ev))
The error message given (without making the above change) included
reference to lazy function evaluation (error history appended at end
of message). So I was wondering whether this is a consequence of my
install failing the LazyFunction test as:
FAIL: test (pymc.tests.test_LazyFunction.test_LazyFunction)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/pymc/tests/
test_LazyFunction.py", line 55, in test
assert(L.ultimate_args.value[1] is C.value)
Many thanks for your time once again,
Regards,
Steve
## Error issued from original code sent
In [3]: ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (34, 0))
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/home/sduni/Python/PyMC/examples/<ipython console> in <module>()
/home/sduni/Python/PyMC/examples/cf_rickerMod.py in <module>()
32
33 # Per capita growth rate is density dependent - Ricker
---> 34 Er = Lambda("Eri", lambda N=N[:-1], ev=ev, rm=rm, K=K: exp(rm
* (1 - (N/K)) + ev))
35
36 # Pmean equal to number this year times per capita rate
/usr/lib/python2.5/site-packages/pymc/CommonDeterministics.pyc in
__init__(self, name, lam_fun, doc, *args, **kwds)
64 parents = dict(zip(parent_names[-len
(parent_values):], parent_values))
65
---> 66 pm.Deterministic.__init__(self, eval=lam_fun,
name=name, parents=parents, doc=doc, *args, **kwds)
67
68 def lambda_deterministic(*args, **kwargs):
/usr/lib/python2.5/site-packages/pymc/PyMCObjects.pyc in __init__
(self, eval, doc, name, parents, dtype, trace, cache_depth, plot,
verbose)
341 trace=trace,
342 plot=plot,
--> 343 verbose=verbose)
344
345 # self._value.force_compute()
/usr/lib/python2.5/site-packages/pymc/Node.pyc in __init__(self, doc,
name, parents, cache_depth, trace, dtype, plot, verbose)
148 self.extended_children = set()
149
--> 150 Node.__init__(self, doc, name, parents, cache_depth,
verbose=verbose)
151
152 if self.dtype is None:
/usr/lib/python2.5/site-packages/pymc/Node.pyc in __init__(self, doc,
name, parents, cache_depth, verbose)
67
68 # Initialize
---> 69 self.parents = parents
70
71 # New lazy function
/usr/lib/python2.5/site-packages/pymc/Node.pyc in _set_parents(self,
new_parents)
90
91 # Get new lazy function
---> 92 self.gen_lazy_function()
93
94 parents = property(_get_parents, _set_parents, doc="Self's
parents: the variables referred to in self's declaration.")
/usr/lib/python2.5/site-packages/pymc/PyMCObjects.pyc in
gen_lazy_function(self)
352 cache_depth =
self._cache_depth)
353
--> 354 self._value.force_compute()
355
356 def get_value(self):
/usr/lib/python2.5/site-packages/pymc/LazyFunction.so in
pymc.LazyFunction.LazyFunction.force_compute()
/home/sduni/Python/PyMC/examples/cf_rickerMod.py in <lambda>(N, ev,
rm, K)
32
33 # Per capita growth rate is density dependent - Ricker
---> 34 Er = Lambda("Eri", lambda N=N[:-1], ev=ev, rm=rm, K=K: exp(rm
* (1 - (N/K)) + ev))
35
36 # Pmean equal to number this year times per capita rate
TypeError: unsupported operand type(s) for /: 'list' and 'float'
AssertionError
# The original code was: