Plotting

ddm.plot.model_gui(model, sample=None, data_dt=0.01, plot=<function plot_fit_diagnostics>, conditions=None, verify=False)[source]

Mess around with model parameters visually.

This allows you to see how the model model would be affected by various changes in parameter values. It also allows you to easily plot sample conditioned on different conditions. A sample is required so that model_gui knows the conditions to include and the ratio of these conditions.

The function plot allows you to change what is plotted. By default, it is plot_fit_diagnostics. If you would like to define your own custom function, it must take four keyword arguments: “model”, the model to plot, “sample”, an optional (defaulting to None) Sample object to potentially compare to the model, “fig”, an optional (defaulting to None) matplotlib figure to plot on, and “conditions”, the conditions selected for plotting. It should not return anything, but it should draw the figure on “fig”.

Because sometimes the model is run in very high resolution, data_dt allows you to set the bin width for sample.

For performance purposes, Paranoid Scientist verification is disabled when running this function. Enable it by setting the verify argument to True.

Some of this code is taken from fit_model.

ddm.plot.model_gui_jupyter(model, sample=None, data_dt=0.01, plot=<function plot_fit_diagnostics>, conditions=None, verify=False)[source]

Mess around with model parameters visually in a Jupyter notebook.

This function is equivalent to model_gui, but displays in a Jupyter notebook with controls. It does nothing when called outside a Jupyter notebook.

ddm.plot.plot_compare_solutions(s1, s2)[source]

Compare two model solutions to each other.

s1 and s2 should be solution objects. This will display a pretty picture of the correct and error distribution pdfs.

ddm.plot.plot_decision_variable_distribution(model, conditions={}, resolution=0.1, figure=None)[source]

Show the distribution of the decision variable.

Show the intermediate distributions for the decision variable. model should be the model to plot, and conditions should be the conditions over which to plot it. resolution should be the timestep of the plot (NOT of the model). Optionally, figure is an existing figure on which to make the plot.

Also, note that for clarity of the visualization, the square root of the distribution is plotted instead of the distribution itself. Without this, it is quite difficult to see the evolving distribution because the distribution of histogram values is highly skewed.

Finally, note that this routine always uses the implicit method because it gives the most reliable histograms for the decision variable. (Crank-Nicoloson tends to oscillate.)

ddm.plot.plot_fit_diagnostics(model=None, sample=None, fig=None, conditions=None, data_dt=0.01, method=None)[source]

Visually assess model fit.

This function plots a model on top of data, primarily for the purpose of assessing the model fit. The plot can be configured with the following arguments:

  • model - The model object to plot. None of the parameters should be “Fittable” instances, they should all be either “Fitted” or numbers.
  • sample - A sample, normally the sample used to fit the model.
  • fig - A matplotlib figure object. If not passed, the current figure will be used.
  • conditions - Optionally restrict the conditions of the model to those specified, in a format which could be passed to Sample.subset.
  • data_dt - Bin size to use for the data histogram. Defaults to 0.01.
  • method - Optionally the method to use to solve the model, either “analytical”, “numerical” “cn”, “implicit”, “explicit”, or None (auto-select, the default).
ddm.plot.plot_solution_cdf(sol, ax=None, correct=True)[source]

Plot the CDF of the solution.

  • ax is optionally the matplotlib axis on which to plot.
  • If correct is true, we draw the distribution of correct answers. Otherwise, we draw the error distributions.

This does not return anything, but it plots the CDF. It does not show it, and thus requires a call to plt.show() to see.

ddm.plot.plot_solution_pdf(sol, ax=None, correct=True)[source]

Plot the PDF of the solution.

  • ax is optionally the matplotlib axis on which to plot.
  • If correct is true, we draw the distribution of correct answers. Otherwise, we draw the error distributions.

This does not return anything, but it plots the PDF. It does not show it, and thus requires a call to plt.show() to see.