Simulator#
- class Simulator(wrapper=None, data=None, parameters=None)[source]#
Bases:
objectA
Simulatorclass for a model in the CPM toolbox. It is designed to run a model for multiple participants and store the output in a format that can be used for further analysis.- Parameters:
- wrapper
Wrapper An initialised Wrapper object for the model.
- datapandas.core.groupby.generic.DataFrameGroupBy or
listof dictionaries The data required for the simulation. If it is a pandas.core.groupby.generic.DataFrameGroupBy, as returned by
pandas.DataFrame.groupby(), each group must contain the data (or environment) for a single participant. If it is a list of dictionaries, each dictionary must contain the data (or environment) for a single participant.- parameters
Parameters,pd.DataFrame,pd.Seriesorlist The parameters required for the simulation. It can be a Parameters object or a list of dictionaries whose length is equal to data. If it is a Parameters object, Simulator will use the same parameters for all simulations. It is a list of dictionaries, it will use match the parameters with data, so that for example parameters[6] will be used for the simulation of data[6].
- wrapper
- Returns:
- simulatorSimulator
A Simulator object.
- run()[source]#
Runs the simulation.
Notes
Data is sorted according to the group IDs as ordered by pandas.
- export(save=False, path=None)[source]#
Return the trial- and participant-level information about the simulation.
- Parameters:
- Returns:
- pandas.DataFrame
A dataframe containing the the model output for each participant and trial. If the output variable is organised as an array with more than one dimension, the output will be flattened.