Issues regarding models using moment-to-moment drift rates #104
-
Hi Max and the PyDDM community, Thanks for developing this awesome library! I'm recently doing some simulation using pyddm. In particular, I'm currently running a model which assumes the drift rates is a function of a moment-to-moment signal presented in the experiment. Everything works fine with the model_gui (btw the GUI is really cool and helpful!), but when I try to solve the model to generate some simulated data, I got an error message: TypeError: can't multiply sequence by non-int of type 'Fittable' I'm guessing this is related to the moment-to-moment drifts, seems like rather than mutiplying the signal at a particular moment by the drift scale, the program multiplies the whole array with the drfit scale. But I'm a bit confused since I passed the conditions parameters to the solve() function in exactly the same way as how I passed it to the model_gui() function. Here are the codes of the model specification: def find_drift(t, slope_vector): model = pyddm.gddm(drift=lambda t,slope_scale,slope_vector : find_drift(t, slope_vector)*slope_scale, Here are the codes for calling model_gui and solving the model, the model_gui works perfectly well, but then I got the TypeError while solving the model: model_gui(model, conditions={"slope_vector": [(0, 2, 0, 2)]}) sol = model.solve(conditions={"slope_vector": [(0, 2, 0, -2)]}) I was wondering why this is happening and how can I possibly fix it. Any advices and comments would be appreciated! Best wishes, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi Yuyang, It looks like there are two issues here, and neither are related to moment-to-moment drifts! Both are related to how you call model.solve. In short, you cannot call model.solve the same way you call model_gui. First, when you call model.solve, you need to specify a single value to solve with for each condition. Here, the value you want is (0, 2, 0, -2). Instead, you are specifying a list of values which only contains one element, namely, [(0, 2, 0, -2)]. By contrast, in model_gui, you can pass a list of elements because then it will average across them and allow you to select them in the list of conditions. I am assuming this was unintended and you meant to use (0, 2, 0, -2), but if you actually do want to solve multiple conditions at once (i.e. [(0, 2, 0, -2)] was intended), you can use pyddm.solve_partial_conditions to get the same behaviour as model_gui. The second issue is that you have not yet fit the parameters of your model before you call model.solve. So you will get an error because the parameters are still unspecified, since they haven't yet been fit to data. Once you fit the model to data and remove the surrounding [] on your slope_vector argument, it should work! |
Beta Was this translation helpful? Give feedback.
Hi Yuyang,
It looks like there are two issues here, and neither are related to moment-to-moment drifts! Both are related to how you call model.solve. In short, you cannot call model.solve the same way you call model_gui.
First, when you call model.solve, you need to specify a single value to solve with for each condition. Here, the value you want is (0, 2, 0, -2). Instead, you are specifying a list of values which only contains one element, namely, [(0, 2, 0, -2)]. By contrast, in model_gui, you can pass a list of elements because then it will average across them and allow you to select them in the list of conditions. I am assuming this was unintended and you meant to use (0, 2, 0, -2), b…