IntegratorFunctions¶
Functions that integrate current value of input with previous value.
- class psyneulink.core.components.functions.stateful.integratorfunctions.SimpleIntegrator(default_variable=None, rate=None, noise=None, offset=None, initializer=None, params=None, owner=None, prefs=None)¶
function
returns:\[previous_value + rate * variable + noise + offset\]Modulatory Parameters:
- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.
rate (float, list or 1d array : default 1.0) – specifies the rate of integration; if it is a list or array, it must be the same length as
variable
(seerate
for details).noise (float, function, list or 1d array : default 0.0) – specifies random value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seenoise
for details).offset (float, list or 1d array : default 0.0) – specifies constant value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seeoffset
for details).initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration; if it is a list or array, it must be the same length as
variable
(seeinitializer
for details).params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
current input value some portion of which (determined by
rate
) will be added to the prior value; if it is an array, each element is independently integrated.- Type
number or array
- rate¶
determines the rate of integration. If it is a float or has a single element, it is applied to all elements
variable
; if it has more than one element, each element is applied to the corresponding element ofvariable
. Serves as MULTIPLICATIVE_PARAM for modulation offunction
.- Type
float or 1d array
- noise¶
random value added to integral in each call to
function
(seenoise
for details).- Type
float, Function or 1d array
- offset¶
constant value added to integral in each call to
function
. Ifvariable
is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation offunction
.- Type
float or 1d array
- initializer¶
determines the starting value(s) for integration (i.e., the value to which
previous_value
is set (seeinitializer
for details).- Type
float or 1d array
- previous_value¶
stores previous value with which
variable
is integrated.- Type
1d array : default class_defaults.variable
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _function(variable=None, context=None, params=None)¶
- Parameters
variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated value of integral
- Return type
2d array
- class psyneulink.core.components.functions.stateful.integratorfunctions.AdaptiveIntegrator(default_variable=None, rate=None, noise=None, offset=None, initializer=None, params=None, owner=None, prefs=None)¶
function
returns exponentially weighted moving average (EWMA) of input:\[((1-rate) * previous_value) + (rate * variable) + noise + offset\]Modulatory Parameters:
- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.
rate (float, list or 1d array : default 1.0) – specifies the smoothing factor of the EWMA. If it is a list or array, it must be the same length as
variable
(seerate
for details).noise (float, function, list or 1d array : default 0.0) – specifies random value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seenoise
for details).offset (float, list or 1d array : default 0.0) – specifies constant value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seeoffset
for details).initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as
variable
(seeinitializer
for details).params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
current input value some portion of which (determined by
rate
) will be added to the prior value; if it is an array, each element is independently integrated.- Type
number or array
- rate¶
determines the smoothing factor of the EWMA. All rate elements must be between 0 and 1 (rate = 0 –> no change,
variable
is ignored; rate = 1 –>previous_value
is ignored). If rate is a float or has a single element, its value is applied to all elements ofvariable
andprevious_value
; if it is an array, each element is applied to the corresponding element ofvariable
andprevious_value
). Serves as MULTIPLICATIVE_PARAM for modulation offunction
.- Type
float or 1d array
- noise¶
random value added to integral in each call to
function
(seenoise
for details).- Type
float, Function or 1d array
- offset¶
constant value added to integral in each call to
function
. Ifvariable
is a list or array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation offunction
.- Type
float or 1d array
- initializer¶
determines the starting value(s) for integration (i.e., the value(s) to which
previous_value
is set (seeinitializer
for details).- Type
float or 1d array
- previous_value¶
stores previous value with which
variable
is integrated.- Type
1d array : default class_defaults.variable
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _validate_params(request_set, target_set=None, context=None)¶
Check inner dimension (length) of all parameters used for the function
- Insure that for any parameters that are in the Parameters class, designated as function_arg, and
specified by the user with length>1: 1) they all have the same length; 2) if default_variable:
was specified by the user, the parameters all have the same length as that
was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below
- _function(variable=None, context=None, params=None)¶
- Parameters
variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated value of integral
- Return type
ndarray (dimension equal to variable)
- class psyneulink.core.components.functions.stateful.integratorfunctions.DriftDiffusionIntegrator(default_variable=None, rate=None, noise=None, offset=None, starting_value=None, non_decision_time=None, threshold=None, time_step_size=None, seed=None, params=None, owner=None, prefs=None, **kwargs)¶
Accumulate “evidence” to a bound.
function
returns one time step of integration:\[previous\_value + rate \cdot variable \cdot time\_step\_size + \mathcal{N}(\sigma^2)\]where
\[\sigma^2 =\sqrt{time\_step\_size \cdot noise}\]Modulatory Parameters:
- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies the stimulus component of drift rate – the drift rate is the product of variable and rate
rate (float, list or 1d array : default 1.0) – applied multiplicatively to
variable
; If it is a list or array, it must be the same length asvariable
(seerate
for details).noise (float : default 0.0) – specifies a value by which to scale the normally distributed random value added to the integral in each call to
function
(seenoise
for details).offset (float, list or 1d array : default 0.0) – specifies constant value added to integral in each call to
function
if it’s absolute value is belowthreshold
; if it is a list or array, it must be the same length asvariable
(seeoffset
for details).starting_value (float, list or 1d array: default 0.0) – specifies the starting value for the integration process; if it is a list or array, it must be the same length as
variable
(seestarting_value
for details).threshold (float : default 0.0) – specifies the threshold (boundaries) of the drift diffusion process – i.e., at which the integration process terminates (see
threshold
for details).time_step_size (float : default 0.0) – specifies the timing precision of the integration process (see
time_step_size
for details.initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as
variable
(seeinitializer
for details).params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
current input value (can be thought of as implementing the stimulus component of the drift rate); if it is an array, each element represents an independently integrated decision variable.
- Type
float or array
- rate¶
applied multiplicatively to
variable
(can be thought of as implementing the attentional component of the drift rate). If it is a float or has a single element, its value is applied to all the elements ofvariable
; if it is an array, each element is applied to the corresponding element ofvariable
. Serves as MULTIPLICATIVE_PARAM for modulation offunction
.- Type
float or 1d array
- random_state¶
private pseudorandom number generator
- Type
numpy.RandomState
- noise¶
scales the normally distributed random value added to integral in each call to
function
. Ifvariable
is a list or array, and noise is a float, a single random term is generated and applied for each element ofvariable
. If noise is a list or array, it must be the same length asvariable
, and a separate random term scaled by noise is applied for each of the corresponding elements ofvariable
.- Type
float or 1d array
- offset¶
constant value added to integral in each call to
function
if it’s absolute value is belowthreshold
. Ifvariable
is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation offunction
.- Type
float or 1d array
- starting_value¶
determines the starting value for the integration process; if it is a list or array, it must be the same length as
variable
. Ifvariable
is an array and starting_value is a float, starting_value is used for each element of the integral; if starting_value is a list or array, each of its elements is used as the starting point for each element of the integral.- Type
float or 1d array
- non_decision_time¶
specifies the starting time of the model and is used to compute
previous_time
- Type
float : default 0.0
- threshold¶
determines the boundaries of the drift diffusion process: the integration process can be scheduled to terminate when the result of
function
equals or exceeds either the positive or negative value of threshold (see hint). NOTE: Vector version of this parameter acts as a saturation barrier. While it is possible to subtract from value == threshold, any movement in the threshold direction will be capped at the threshold value.Hint
To terminate execution of the Mechanism to which the
function
is assigned, aWhenFinished
Condition should be assigned for that Mechanism toscheduler
of the Composition to which the Mechanism belongs.- Type
float
- time_step_size¶
determines the timing precision of the integration process and is used to scale the
noise
parameter according to the standard DDM probability distribution.- Type
float
- initializer¶
determines the starting value(s) for integration (i.e., the value(s) to which
previous_value
is set (seeinitializer
for details).- Type
float or 1d array
- previous_time¶
stores previous time at which the function was executed and accumulates with each execution according to
time_step_size
.- Type
float
- previous_value¶
stores previous value with which
variable
is integrated.- Type
1d array : default class_defaults.variable
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _function(variable=None, context=None, params=None)¶
- Parameters
variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated (can be thought of as the stimulus component of the drift rate).
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated value of integral
- Return type
2d array
- reset(previous_value=None, previous_time=None, context=None)¶
Resets
value
andprevious_value
to the specified value(s).If arguments are passed into the reset method, then reset sets each of the attributes in
stateful_attributes
to the value of the corresponding argument. Next, it sets thevalue
to a list containing each of the argument values.If reset is called without arguments, then it sets each of the attributes in
stateful_attributes
to the value of the corresponding attribute ininitializers
. Next, it sets thevalue
to a list containing the values of each of the attributes ininitializers
.Often, the only attribute in
stateful_attributes
isprevious_value
and the only attribute ininitializers
isinitializer
, in which case the reset method setsprevious_value
andvalue
to either the value of the argument (if an argument was passed into reset) or the current value ofinitializer
.For specific types of StatefulFunction functions, the reset method may carry out other reinitialization steps.
- _assign_to_mdf_model(model, input_id)¶
Adds an MDF representation of this function to MDF object model, including all necessary auxiliary functions. input_id is the input to the singular MDF function or first function representing this psyneulink Function, if applicable.
- Returns
the identifier of the final MDF function representing this psyneulink Function
- Return type
str
- class psyneulink.core.components.functions.stateful.integratorfunctions.DriftOnASphereIntegrator(default_variable=None, rate=None, noise=None, offset=None, starting_point=None, time_step_size=None, dimension=None, initializer=None, angle_function=None, seed=None, params=None, owner=None, prefs=None, **kwargs)¶
Drift and diffuse on a sphere.
function
integrates previous coordinates with drift and/or noise that is applied either equally to all coordinates or dimension by dimension:\[previous\_value + rate \cdot variable \cdot time\_step\_size + \mathcal{N}(\sigma^2)\]where
\[\sigma^2 =\sqrt{time\_step\_size \cdot noise}\]Modulatory Parameters:
- Parameters
default_variable (list or 1d array : default class_defaults.variable) – specifies template for drift: if specified, its length must be 1 or the value specified for dimension minus 1 (see
variable
for additional details).rate (float, list or 1d array : default 1.0) – applied multiplicatively to
variable
; If it is a list or array, it must be the same length asvariable
(seerate
for details).noise (float : default 0.0) – specifies a value by which to scale the normally distributed random value added to the integral in each call to
function
(seenoise
for details).offset (float, list or 1d array : default 0.0) – specifies constant value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seeoffset
for details).starting_point (float, list or 1d array: default 0.0) – specifies the starting value for the integration process; if it is a list or array, it must be the same length as
variable
(seestarting_point
for details).time_step_size (float : default 0.0) – specifies the timing precision of the integration process (see
time_step_size
for details.dimension (int : default 2) – specifies dimensionality of the sphere over which drift occurs.
initializer (1d array : default [0]) – specifies the starting point on the sphere from which angle is derived; its length must be equal to
dimension
(seeinitializer
for additional details).angle_function (TransferFunction : default Angle) – specifies function used to compute angle from position on sphere specified by coordinates in
previous_value
.params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
current input value that determines rate of drift on the sphere. If it is a scalar, it is applied equally to all coordinates (subject to
noise
; if it is an array, each element determines rate of drift over a given dimension; coordinate values are integrated over each execution, with the previous set stored inprevious_value
.- Type
float or array
- rate¶
applied multiplicatively to
variable
(can be thought of as implementing the attentional component of the drift rate). If it is a float or has a single element, its value is applied to all the elements ofvariable
; if it is an array, each element is applied to the corresponding element ofvariable
. Serves as MULTIPLICATIVE_PARAM for modulation offunction
.- Type
float or 1d array
- random_state¶
private pseudorandom number generator
- Type
numpy.RandomState
- noise¶
scales the normally distributed random value added to integral in each call to
function
. Ifvariable
is a list or array, and noise is a float, a single random term is generated and applied for each element ofvariable
. If noise is a list or array, it must be the same length asvariable
, and a separate random term scaled by noise is applied for each of the corresponding elements ofvariable
.- Type
float or 1d array
- offset¶
constant value added to integral in each call to
function
. Ifvariable
is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation offunction
.- Type
float or 1d array
- starting_point¶
determines the starting value for the integration process; if it is a list or array, it must be the same length as
variable
. Ifvariable
is an array and starting_point is a float, starting_point is used for each element of the integral; if starting_point is a list or array, each of its elements is used as the starting point for each element of the integral.- Type
float or 1d array
- time_step_size¶
determines the timing precision of the integration process and is used to scale the
noise
parameter.- Type
float
- dimension¶
determines dimensionality of sphere on which drift occurs.
- Type
int
- initializer¶
determines the starting point on the sphere from which angle is derived; its length must be equal to
dimension
.- Type
1d array
- angle_function¶
determines the function used to compute angle (reported as result) from coordinates on sphere specified by coordinates in
previous_value
displaced byvariable
and possiblynoise
.- Type
- previous_time¶
stores previous time at which the function was executed and accumulates with each execution according to
time_step_size
.- Type
float
- previous_value¶
stores previous set of coordinates on sphere over which drift is occuring.
- Type
1d array : default class_defaults.variable
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _validate_params(request_set, target_set=None, context=None)¶
Check inner dimension (length) of all parameters used for the function
- Insure that for any parameters that are in the Parameters class, designated as function_arg, and
specified by the user with length>1: 1) they all have the same length; 2) if default_variable:
was specified by the user, the parameters all have the same length as that
was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below
- _validate_initializers(default_variable, context=None)¶
Need to override this to manage mismatch in dimensionality of initializer vs. variable
- _instantiate_attributes_before_function(function=None, context=None)¶
Need to override this to manage mismatch in dimensionality of initializer vs. variable
- _validate(context=None)¶
Validate angle_function
- _function(variable=None, context=None, params=None)¶
- Parameters
variable (number, list or 1d array : default class_defaults.variable) – value used as drift; if it is a number, then used for all coordinates; if it is list or array its length must equal
dimension
- 1, and is applied Hadamard to each coordinate.params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated coordinates
- Return type
1d array
- reset(previous_value=None, previous_time=None, context=None)¶
Resets
value
andprevious_value
to the specified value(s).If arguments are passed into the reset method, then reset sets each of the attributes in
stateful_attributes
to the value of the corresponding argument. Next, it sets thevalue
to a list containing each of the argument values.If reset is called without arguments, then it sets each of the attributes in
stateful_attributes
to the value of the corresponding attribute ininitializers
. Next, it sets thevalue
to a list containing the values of each of the attributes ininitializers
.Often, the only attribute in
stateful_attributes
isprevious_value
and the only attribute ininitializers
isinitializer
, in which case the reset method setsprevious_value
andvalue
to either the value of the argument (if an argument was passed into reset) or the current value ofinitializer
.For specific types of StatefulFunction functions, the reset method may carry out other reinitialization steps.
- class psyneulink.core.components.functions.stateful.integratorfunctions.OrnsteinUhlenbeckIntegrator(default_variable=None, rate=None, decay=None, noise=None, offset=None, non_decision_time=None, time_step_size=None, starting_value=None, params=None, seed=None, owner=None, prefs=None, **kwargs)¶
function
returns one time step of integration according to an Ornstein Uhlenbeck process:\[previous\_value + (decay \cdot previous\_value) - (rate \cdot variable) + \mathcal{N}(\sigma^2)\]where
\[\sigma^2 =\sqrt{time\_step\_size \cdot noise}\]Modulatory Parameters:
- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies a template for the stimulus component of drift rate – the drift rate is the product of variable and rate
rate (float, list or 1d array : default 1.0) – specifies value applied multiplicatively to
variable
; If it is a list or array, it must be the same length asvariable
(seerate
for details).decay (float, list or 1d array : default 1.0) – specifies value applied multiplicatively to
previous_value
; If it is a list or array, it must be the same length asvariable
( seedecay
for details).noise (float : default 0.0) – specifies a value by which to scale the normally distributed random value added to the integral in each call to
function
(seenoise
for details).offset (float, list or 1d array : default 0.0) – specifies a constant value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seeoffset
for details)non_decision_time (float : default 0.0) – specifies the starting time of the model and is used to compute
previous_time
time_step_size (float : default 0.0) – determines the timing precision of the integration process (see
time_step_size
for details.initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as
variable
(seeinitializer
for details).params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
represents the stimulus component of drift. The product of
variable
andrate
is multiplied bytime_step_size
to model the accumulation of evidence during one step.- Type
number or array
- rate¶
applied multiplicatively to
variable
. If it is a float or has a single element, its value is applied to all the elements ofvariable
; if it is an array, each element is applied to the corresponding element ofvariable
. Serves as MULTIPLICATIVE_PARAM for modulation offunction
.- Type
float or 1d array
- decay¶
applied multiplicatively to
previous_value
; If it is a float or has a single element, its value is applied to all the elements ofprevious_value
; if it is an array, each element is applied to the corresponding element ofprevious_value
.- Type
float or 1d array
- noise¶
scales the normally distributed random value added to integral in each call to
function
. A single random term is generated each execution, and applied to all elements ofvariable
if that is an array with more than one element.- Type
float
- offset¶
constant value added to integral in each call to
function
. Ifvariable
is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation offunction
.- Type
float or 1d array
- non_decision_time¶
determines the start time of the integration process.
- Type
float
- time_step_size¶
determines the timing precision of the integration process and is used to scale the
noise
parameter appropriately.- Type
float
- initializer¶
determines the starting value(s) for integration (i.e., the value(s) to which
previous_value
is set (seeinitializer
for details).- Type
float or 1d array
- previous_value¶
stores previous value with which
variable
is integrated.- Type
1d array : default class_defaults.variable
- previous_time¶
stores previous time at which the function was executed and accumulates with each execution according to
time_step_size
.- Type
float
- random_state¶
private pseudorandom number generator
- Type
numpy.RandomState
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _function(variable=None, context=None, params=None)¶
- Parameters
variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated value of integral
- Return type
2d array
- reset(previous_value=None, previous_time=None, context=None)¶
Resets
value
andprevious_value
to the specified value(s).If arguments are passed into the reset method, then reset sets each of the attributes in
stateful_attributes
to the value of the corresponding argument. Next, it sets thevalue
to a list containing each of the argument values.If reset is called without arguments, then it sets each of the attributes in
stateful_attributes
to the value of the corresponding attribute ininitializers
. Next, it sets thevalue
to a list containing the values of each of the attributes ininitializers
.Often, the only attribute in
stateful_attributes
isprevious_value
and the only attribute ininitializers
isinitializer
, in which case the reset method setsprevious_value
andvalue
to either the value of the argument (if an argument was passed into reset) or the current value ofinitializer
.For specific types of StatefulFunction functions, the reset method may carry out other reinitialization steps.
- class psyneulink.core.components.functions.stateful.integratorfunctions.FitzHughNagumoIntegrator(default_variable=None, initial_w=None, initial_v=None, a_v=None, b_v=None, c_v=None, d_v=None, e_v=None, f_v=None, time_constant_v=None, a_w=None, b_w=None, c_w=None, time_constant_w=None, t_0=None, threshold=None, time_step_size=None, mode=None, uncorrelated_activity=None, integration_method=None, params=None, owner=None, prefs=None, **kwargs)¶
function
returns one time step of integration of the `Fitzhugh-Nagumo model https://en.wikipedia.org/wiki/FitzHugh–Nagumo_model>`_ of an excitable oscillator:\[time\_constant_v \frac{dv}{dt} = a_v * v^3 + (1 + threshold) * b_v * v^2 + (- threshold) * c_v * v^2 + d_v + e_v * w + f_v * I_{ext}\]where .. math:
time\_constant_w * \frac{dw}{dt} =` mode * a_w * v + b_w * w +c_w + (1 - mode) * uncorrelated\_activity
Either Euler or Dormand–Prince (4th Order Runge-Kutta) methods of numerical integration can be used.
The FitzHughNagumoIntegrator implements all of the parameters of the FitzHughNagumo model; however, not all combinations of these are sensible. Typically, they are combined into two sets. These are described below, followed by a describption of how they are used to implement three common variants of the model with the FitzHughNagumoIntegrator.
Fast, Excitatory Variable:
\[\frac{dv}{dt} = \frac{a_v v^{3} + b_v v^{2} (1+threshold) - c_v v\, threshold + d_v + e_v\, previous_w + f_v\, variable)}{time\, constant_v}\]Slow, Inactivating Variable:
\[\frac{dw}{dt} = \frac{a_w\, mode\, previous_v + b_w w + c_w + uncorrelated\,activity\,(1-mode)}{time\, constant_w}\]Fitzhugh-Nagumo Model
Fast, Excitatory Variable:
\[\frac{dv}{dt} = v - \frac{v^3}{3} - w + I_{ext}\]Slow, Inactivating Variable:
\[\frac{dw}{dt} = \frac{v + a - bw}{T}\]\(\frac{dw}{dt}\) often has the following parameter values:
\[\frac{dw}{dt} = 0.08\,(v + 0.7 - 0.8 w)\]Implementation in FitzHughNagumoIntegrator
The default values implement the above equations.
Modified FitzHughNagumo Model
Fast, Excitatory Variable:
\[\frac{dv}{dt} = v(a-v)(v-1) - w + I_{ext}\]Slow, Inactivating Variable:
\[\frac{dw}{dt} = bv - cw\]Mahbub Khan (2013) provides a nice summary of why this formulation is useful.
Implementation in FitzHughNagumoIntegrator
The following parameter values must be specified in the equation for \(\frac{dv}{dt}\):
FitzHughNagumoIntegrator Parameter
a_v
b_v
c_v
d_v
e_v
f_v
time_constant_v
Value
-1.0
1.0
1.0
0.0
-1.0
1.0
1.0
When the parameters above are set to the listed values, the FitzHughNagumoIntegrator equation for \(\frac{dv}{dt}\) reduces to the Modified FitzHughNagumo formulation, and the remaining parameters in the \(\frac{dv}{dt}\) equation correspond as follows:
FitzHughNagumoIntegrator Parameter
Modified FitzHughNagumo Parameter
a
\(I_{ext}\)
The following parameter values must be set in the equation for \(\frac{dw}{dt}\):
FitzHughNagumoIntegrator Parameter
c_w
mode
time_constant_w
uncorrelated_activity
Value
0.0
1.0
1.0
0.0
When the parameters above are set to the listed values, the FitzHughNagumoIntegrator equation for \(\frac{dw}{dt}\) reduces to the Modified FitzHughNagumo formulation, and the remaining parameters in the \(\frac{dw}{dt}\) equation correspond as follows:
FitzHughNagumoIntegrator Parameter
NEGATIVE
b_w
Modified FitzHughNagumo Parameter
b
c
Modified FitzHughNagumo Model as implemented in Gilzenrat (2002)
Fast, Excitatory Variable:
[Eq. (6) in Gilzenrat (2002) ]
\[\tau_v \frac{dv}{dt} = v(a-v)(v-1) - u + w_{vX_1}\, f(X_1)\]Slow, Inactivating Variable:
[Eq. (7) & Eq. (8) in Gilzenrat (2002) ]
\[\tau_u \frac{du}{dt} = Cv + (1-C)\, d - u\]Implementation in FitzHughNagumoIntegrator
The following FitzHughNagumoIntegrator parameter values must be set in the equation for \(\frac{dv}{dt}\):
FitzHughNagumoIntegrator Parameter
a_v
b_v
c_v
d_v
e_v
Value
-1.0
1.0
1.0
0.0
-1.0
When the parameters above are set to the listed values, the FitzHughNagumoIntegrator equation for \(\frac{dv}{dt}\) reduces to the Gilzenrat formulation, and the remaining parameters in the \(\frac{dv}{dt}\) equation correspond as follows:
FitzHughNagumoIntegrator Parameter
f_v
Gilzenrat Parameter
a
\(f(X_1)\)
\(w_{vX_1}\) |\(T_{v}\)
The following FitzHughNagumoIntegrator parameter values must be set in the equation for \(\frac{dw}{dt}\):
FitzHughNagumoIntegrator Parameter
a_w
b_w
c_w
Value
1.0
-1.0
0.0
When the parameters above are set to the listed values, the FitzHughNagumoIntegrator equation for \(\frac{dw}{dt}\) reduces to the Gilzenrat formulation, and the remaining parameters in the \(\frac{dw}{dt}\) equation correspond as follows:
FitzHughNagumoIntegrator Parameter
Gilzenrat Parameter
C
d
\(T_{u}\)
- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies a template for the external stimulus
initial_w (float, list or 1d array : default 0.0) – specifies starting value for integration of dw/dt. If it is a list or array, it must be the same length as
variable
.initial_v (float, list or 1d array : default 0.0) – specifies starting value for integration of dv/dt. If it is a list or array, it must be the same length as
variable
time_step_size (float : default 0.1) – specifies the time step size of numerical integration
t_0 (float : default 0.0) – specifies starting value for time
a_v (float : default -1/3) – coefficient on the v^3 term of the dv/dt equation
b_v (float : default 0.0) – coefficient on the v^2 term of the dv/dt equation
c_v (float : default 1.0) – coefficient on the v term of the dv/dt equation
d_v (float : default 0.0) – constant term in the dv/dt equation
e_v (float : default -1.0) – coefficient on the w term in the dv/dt equation
f_v (float : default 1.0) – coefficient on the external stimulus (
variable
) term in the dv/dt equationtime_constant_v (float : default 1.0) – scaling factor on the dv/dt equation
a_w (float : default 1.0,) – coefficient on the v term of the dw/dt equation
b_w (float : default -0.8,) – coefficient on the w term of the dv/dt equation
c_w (float : default 0.7,) – constant term in the dw/dt equation
threshold (float : default -1.0) – specifies a value of the input below which the LC will tend not to respond and above which it will
mode (float : default 1.0) – coefficient which simulates electrotonic coupling by scaling the values of dw/dt such that the v term (representing the input from the LC) increases when the uncorrelated_activity term (representing baseline activity) decreases
uncorrelated_activity (float : default 0.0) – constant term in the dw/dt equation
time_constant_w (float : default 12.5) – scaling factor on the dv/dt equation
integration_method (str : default "RK4") – selects the numerical integration method. Currently, the choices are: “RK4” (4th Order Runge-Kutta) or “EULER” (Forward Euler)
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
External stimulus
- Type
number or array
- previous_v¶
stores accumulated value of v during integration
- Type
1d array : default class_defaults.variable
- previous_w¶
stores accumulated value of w during integration
- Type
1d array : default class_defaults.variable
- previous_t¶
stores accumulated value of time, which is incremented by time_step_size on each execution of the function
- Type
float
- initial_w¶
specifies starting value for integration of dw/dt. If it is a list or array, it must be the same length as
variable
- Type
float, list or 1d array : default 0.0
- initial_v¶
specifies starting value for integration of dv/dt. If it is a list or array, it must be the same length as
variable
- Type
float, list or 1d array : default 0.0
- time_step_size¶
specifies the time step size of numerical integration
- Type
float : default 0.1
- t_0¶
specifies starting value for time
- Type
float : default 0.0
- a_v¶
coefficient on the v^3 term of the dv/dt equation
- Type
float : default -1/3
- b_v¶
coefficient on the v^2 term of the dv/dt equation
- Type
float : default 0.0
- c_v¶
coefficient on the v term of the dv/dt equation
- Type
float : default 1.0
- d_v¶
constant term in the dv/dt equation
- Type
float : default 0.0
- e_v¶
coefficient on the w term in the dv/dt equation
- Type
float : default -1.0
- f_v¶
coefficient on the external stimulus (
variable
) term in the dv/dt equation- Type
float : default 1.0
- time_constant_v¶
scaling factor on the dv/dt equation
- Type
float : default 1.0
- a_w¶
coefficient on the v term of the dw/dt equation
- Type
float : default 1.0
- b_w¶
coefficient on the w term of the dv/dt equation
- Type
float : default -0.8
- c_w¶
constant term in the dw/dt equation
- Type
float : default 0.7
- threshold¶
coefficient that scales both the v^2 [ (1+threshold)*v^2 ] and v [ (-threshold)*v ] terms in the dv/dt equation under a specific formulation of the FitzHughNagumo equations, the threshold parameter behaves as a “threshold of excitation”, and has the following relationship with variable (the external stimulus):
when the external stimulus is below the threshold of excitation, the system is either in a stable state, or will emit a single excitation spike, then reach a stable state. The behavior varies depending on the magnitude of the difference between the threshold and the stimulus.
when the external stimulus is equal to or above the threshold of excitation, the system is unstable, and will emit many excitation spikes
when the external stimulus is too far above the threshold of excitation, the system will emit some excitation spikes before reaching a stable state.
- Type
float : default -1.0
- mode¶
coefficient which simulates electrotonic coupling by scaling the values of dw/dt such that the v term (representing the input from the LC) increases when the uncorrelated_activity term (representing baseline activity) decreases
- Type
float : default 1.0
constant term in the dw/dt equation
- Type
float : default 0.0
- time_constant_w¶
scaling factor on the dv/dt equation
- Type
float : default 12.5
- prefs¶
the
PreferenceSet
for the Function (seeprefs
for details).- Type
PreferenceSet or specification dict : default Function.classPreferences
- _validate_params(request_set, target_set=None, context=None)¶
Check inner dimension (length) of all parameters used for the function
- Insure that for any parameters that are in the Parameters class, designated as function_arg, and
specified by the user with length>1: 1) they all have the same length; 2) if default_variable:
was specified by the user, the parameters all have the same length as that
was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below
- _function(variable=None, context=None, params=None)¶
- Parameters
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
current value of v , current value of w, current time_step of integration
- Return type
ndarray
- reset(previous_v=None, previous_w=None, previous_time=None, context=None)¶
Resets
value
andprevious_value
to the specified value(s).If arguments are passed into the reset method, then reset sets each of the attributes in
stateful_attributes
to the value of the corresponding argument. Next, it sets thevalue
to a list containing each of the argument values.If reset is called without arguments, then it sets each of the attributes in
stateful_attributes
to the value of the corresponding attribute ininitializers
. Next, it sets thevalue
to a list containing the values of each of the attributes ininitializers
.Often, the only attribute in
stateful_attributes
isprevious_value
and the only attribute ininitializers
isinitializer
, in which case the reset method setsprevious_value
andvalue
to either the value of the argument (if an argument was passed into reset) or the current value ofinitializer
.For specific types of StatefulFunction functions, the reset method may carry out other reinitialization steps.
- _assign_to_mdf_model(model, input_id)¶
Adds an MDF representation of this function to MDF object model, including all necessary auxiliary functions. input_id is the input to the singular MDF function or first function representing this psyneulink Function, if applicable.
- Returns
the identifier of the final MDF function representing this psyneulink Function
- Return type
str
- class psyneulink.core.components.functions.stateful.integratorfunctions.AccumulatorIntegrator(default_variable=None, rate=None, increment=None, noise=None, initializer=None, params=None, owner=None, prefs=None)¶
Accumulates at a constant rate, that is either linear or exponential, depending on
rate
.function
ignoresvariable
and returns:\[previous\_value \cdot rate + increment + noise\]so that, with each call to
function
, the accumulated value increases by:\[increment \cdot rate^{time\_step}.\]Thus, accumulation increases lineary in steps of
increment
ifrate
=1.0, and exponentially otherwise.Modulatory Parameters:
- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.
rate (float, list or 1d array : default 1.0) – specifies the rate of decay; if it is a list or array, it must be the same length as
variable
(seerate
for additional details.increment (float, list or 1d array : default 0.0) – specifies an amount to be added to
previous_value
in each call tofunction
; if it is a list or array, it must be the same length asvariable
(seeincrement
for details).noise (float, Function, list or 1d array : default 0.0) – specifies random value added to
prevous_value
in each call tofunction
; if it is a list or array, it must be the same length asvariable
(seenoise
for additional details).initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as
variable
(seeinitializer
for details).params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
Ignored by the AccumulatorIntegrator function. Use
LeakyCompetingIntegrator
orAdaptiveIntegrator
for integrator functions that depend on both a prior value and a new value (variable).- Type
number or array
- rate¶
determines the rate of exponential decay of
previous_value
in each call tofunction
. If it is a float or has a single element, its value is applied to all the elements ofprevious_value
; if it is an array, each element is applied to the corresponding element ofprevious_value
. Serves as MULTIPLICATIVE_PARAM for modulation offunction
.- Type
float or 1d array
- increment¶
determines the amount added to
previous_value
in each call tofunction
. If it is a list or array, it must be the same length asvariable
and each element is added to the corresponding element ofprevious_value
(i.e., it is used for Hadamard addition). If it is a scalar or has a single element, its value is added to all the elements ofprevious_value
. Serves as ADDITIVE_PARAM for modulation offunction
.- Type
float, function, or 1d array
- noise¶
random value added in each call to
function
(seenoise
for details).- Type
float, Function or 1d array
- initializer¶
determines the starting value(s) for integration (i.e., the value(s) to which
previous_value
is set (seeinitializer
for details).- Type
float or 1d array
- previous_value¶
stores previous value to which
rate
andnoise
will be added.- Type
1d array : default class_defaults.variable
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _accumulator_check_args(variable=None, context=None, params=None, target_set=None)¶
validate params and assign any runtime params.
Called by AccumulatorIntegrator to validate params Validation can be suppressed by turning parameter_validation attribute off target_set is a params dictionary to which params should be assigned;
Does the following: - assign runtime params to context - validate params if PARAM_VALIDATION is set
- Parameters
params – (dict) - params to validate
- Target_set
(dict) - set to which params should be assigned
- Returns
- _function(variable=None, context=None, params=None)¶
- Parameters
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated value of integral
- Return type
2d array
- class psyneulink.core.components.functions.stateful.integratorfunctions.LeakyCompetingIntegrator(default_variable=None, leak=None, noise=None, offset=None, time_step_size=None, initializer=None, params=None, owner=None, prefs=None, **kwargs)¶
Implements Leaky Competitive Accumulator (LCA) described in Usher & McClelland (2001).
function
returns:\[previous\_value + (variable - leak \cdot previous\_value) \cdot time\_step\_size + noise \sqrt{time\_step\_size}\]where
variable
corresponds to \(\rho_i\) + \(\beta\)\(\Sigma f(x_{\neq i})\) (the net input to a unit),leak
corresponds to \(k\), andtime_step_size
corresponds to \(\frac{dt}{\tau}\) in Equation 4 of Usher & McClelland (2001).Note
When used as the
function
of an LCAMechanism, the value passed tovariable
is the sum of the external and recurrent inputs to the Mechanism (see here for how the external and recurrent inputs can be configured in a RecurrentTransferMechanism, of which LCAMechanism is subclass).Note
the value of the leak argument is assigned to the
rate
parameter (and theleak
parameter as an alias of therate
parameter); this is to be consistent with the parent class,IntegratorFunction
. However, note that in contrast to a standard IntegratorFunction, where \(rate \cdot previous\_value\) is added tovariable
, here it is subtracted fromvariable
in order to implement decay. Thus, the value returned by the function can increase in a given time step only ifrate
(akaleak
) is negative orvariable
is sufficiently positive.Modulatory Parameters:
- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.
leak (float, list or 1d array : default 1.0) – specifies the value used to scale the rate of decay of the integral on each time step. If it is a list or array, it must be the same length as
variable
(seeleak
for details).noise (float, function, list or 1d array : default 0.0) – specifies random value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seenoise
for additonal details).offset (float, list or 1d array : default 0.0) – specifies a constant value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seeoffset
for details).time_step_size (float : default 0.0) – specifies the timing precision of the integration process (see
time_step_size
for details.initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as
variable
(seeinitializer
for details).params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
current input value some portion of which (determined by
rate
) will be added to the prior value; if it is an array, each element is independently integrated.- Type
number or array
- rate¶
scales the contribution of
previous_value
to the decay of thevalue
on each time step (corresponding to theleak
term of the function described in Equation 4 of Usher & McClelland, 2001). If it is a float or has a single element, its value is applied to all the elements ofprevious_value
; if it is an array, each element is applied to the corresponding element ofprevious_value
. Serves as MULTIPLICATIVE_PARAM for modulation offunction
.Note
aliased by the
leak
parameter.- Type
float, list or 1d array
- leak¶
alias of
rate
(to be consistent with the standard format of anIntegratorFunction
).- Type
float, list or 1d array
- noise¶
random value added to integral in each call to
function
. (seenoise
for details).- Type
float, Function, or 1d array
- offset¶
constant value added to integral in each call to
function
. Ifvariable
is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation offunction
.- Type
float or 1d array
- time_step_size¶
determines the timing precision of the integration process and is used to scale the
noise
parameter appropriately.- Type
float
- initializer¶
determines the starting value(s) for integration (i.e., the value(s) to which
previous_value
is set (seeinitializer
for details).- Type
float or 1d array
- previous_value¶
stores previous value with which
variable
is integrated.- Type
1d array : default class_defaults.variable
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _function(variable=None, context=None, params=None)¶
- Parameters
variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated value of integral
- Return type
2d array
- class psyneulink.core.components.functions.stateful.integratorfunctions.DualAdaptiveIntegrator(default_variable=None, initializer=None, initial_short_term_avg=None, initial_long_term_avg=None, short_term_gain=None, long_term_gain=None, short_term_bias=None, long_term_bias=None, short_term_rate=None, long_term_rate=None, operation=None, offset=None, params=None, owner=None, prefs=None)¶
Combines two exponentially weighted moving averages (EWMA) of its input, each with a different rate, as implemented in Aston-Jones & Cohen (2005) to integrate utility over two time scales.
function
computes the EWMA ofvariable
using two integration rates (short_term_rate
andlong_term_rate
), transforms each using a logistic function, and then combines them, as follows:short time scale integral:
\[short\_term\_avg = short\_term\_rate \cdot variable + (1 - short\_term\_rate) \cdot previous\_short\_term\_avg\]long time scale integral:
\[long\_term\_avg = long\_term\_rate \cdot variable + (1 - long\_term\_rate) \cdot previous\_long\_term\_avg\]
combined integral:
\[value = operation(1-\frac{1}{1+e^{short\_term\_gain\ \cdot\ short\_term\_avg\ +\ short\_term\_bias}},\ \frac{1}{1+e^{long\_term\_gain\ \cdot\ long\_term\_avg + long\_term\_bias}})\ +\ offset\]where operation is the arithmetic
operation
used to combine the terms.
Modulatory Parameters:
ADDITIVE_PARAM:offset
- Parameters
initial_short_term_avg (float : default 0.0) – specifies starting value for integration of short_term_avg
initial_long_term_avg (float : default 0.0) – specifies starting value for integration of long_term_avg
short_term_gain (float : default 1.0) – specifies gain for logistic function applied to short_term_avg
long_term_gain (float : default 1.0) – specifies gain for logistic function applied to long_term_avg
short_term_bias (float : default 0.0) – specifies bias for logistic function applied to short_term_avg
long_term_bias (float : default 0.0) – specifies bias for logistic function applied to long_term_avg
short_term_rate (float : default 1.0) – specifies smoothing factor of EWMA filter applied to short_term_avg
long_term_rate (float : default 1.0) – specifies smoothing factor of EWMA filter applied to long_term_avg
operation (PRODUCT, SUM, S_MINUS_L or L_MINUS_S : default PRODUCT) – specifies the arithmetic operation used to combine the logistics of the short_term_avg and long_term_avg (see
operation
for details).offset (float or 1d array) – constant value added to integral in each call to
function
after logistics of short_term_avg and long_term_avg are combined; if it is a list or array, it must be the same length asvariable
(seeoffset
for details.params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
current input value used to compute both the short term and long term EWMA averages.
- Type
number or array
- initial_short_term_avg¶
determines starting value for integration of short_term_avg
- Type
float
- initial_long_term_avg¶
determines starting value for integration of long_term_avg
- Type
float
- short_term_gain¶
determines gain for logistic function applied to short_term_avg
- Type
float
- long_term_gain¶
determines gain for logistic function applied to long_term_avg
- Type
float
- short_term_bias¶
determines bias for logistic function applied to short_term_avg
- Type
float
- long_term_bias¶
determines bias for logistic function applied to long_term_avg
- Type
float
- operation¶
determines the arithmetic operation used to combine short_term_logistic and long_term_logistic:
PRODUCT = (1 - short_term_logistic) * long_term_logistic
SUM = (1 - short_term_logistic) + long_term_logistic
S_MINUS_L = (1 - short_term_logistic) - long_term_logistic
L_MINUS_S = long_term_logistic - (1 - short_term_logistic)
- Type
str
- offset¶
constant value added to integral in each call to
function
after logistics of short_term_avg and long_term_avg are combined. Ifvariable
is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation offunction
.- Type
float or 1d array
- previous_short_term_avg¶
stores previous value with which
variable
is integrated using the EWMA filter and short term parameters- Type
1d array
- previous_long_term_avg¶
stores previous value with which
variable
is integrated using the EWMA filter and long term parameters- Type
1d array
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _validate_params(request_set, target_set=None, context=None)¶
Check inner dimension (length) of all parameters used for the function
- Insure that for any parameters that are in the Parameters class, designated as function_arg, and
specified by the user with length>1: 1) they all have the same length; 2) if default_variable:
was specified by the user, the parameters all have the same length as that
was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below
- _function(variable=None, context=None, params=None)¶
- Parameters
variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated value of integral
- Return type
2d array
- reset(short=None, long=None, context=NotImplemented)¶
Effectively begins accumulation over again at the specified utilities.
Sets
previous_short_term_avg
to the quantity specified in the first argument andprevious_long_term_avg
to the quantity specified in the second argument.Sets
value
by computing it based on the newly updated values forprevious_short_term_avg
andprevious_long_term_avg
.If no arguments are specified, then the current values of
initial_short_term_avg
andinitial_long_term_avg
are used.
- class psyneulink.core.components.functions.stateful.integratorfunctions.InteractiveActivationIntegrator(default_variable=None, rate=None, decay=None, rest=None, max_val=None, min_val=None, noise=None, initializer=None, params=None, owner=None, prefs=None)¶
Implements a generalized version of the interactive activation from McClelland and Rumelhart (1981) that integrates current value of
variable
toward an asymptotic maximum valuemax_val
for positive inputs and toward an asymptotic mininum value (min_val
) for negative inputs, and decays asymptotically towards an intermediate resting value (rest
).function
returns:\[previous\_value + (rate * (variable + noise) * distance\_from\_asymptote) - (decay * distance\_from\_rest)\]where:
\[if\ variable > 0,\ distance\_from\_asymptote = max\_val - previous\_value\]\[if\ variable < 0,\ distance\_from\_asymptote = previous\_value - min\_val\]\[if\ variable = 0,\ distance\_from\_asymptote = 0\]- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.
rate (float, list or 1d array : default 1.0) – specifies the rate of change in activity; its value(s) must be in the interval [0,1]. If it is a list or array, it must be the same length as
variable
.decay (float, list or 1d array : default 1.0) – specifies the rate of at which activity decays toward
rest
. If it is a list or array, it must be the same length asvariable
; its value(s) must be in the interval [0,1].rest (float, list or 1d array : default 0.0) – specifies the initial value and one toward which value
decays
. If it is a list or array, it must be the same length asvariable
.max_val (float, list or 1d array : default 1.0) – specifies the maximum asymptotic value toward which integration occurs for positive values of
variable
. If it is a list or array, it must be the same length asvariable
; all values must be greater than the corresponding values ofmin_val
(seemax_val
for details).min_val (float, list or 1d array : default 1.0) – specifies the minimum asymptotic value toward which integration occurs for negative values of
variable
. If it is a list or array, it must be the same length asvariable
; all values must be greater than the corresponding values ofmax_val
(seemax_val
for details).noise (float, function, list or 1d array : default 0.0) – specifies random value added to
variable
in each call tofunction
; if it is a list or array, it must be the same length asvariable
(seenoise
for details).initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as
variable
(seeinitializer
for details).params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
current input value some portion of which (determined by
rate
) will be added to the prior value; if it is an array, each element is independently integrated.- Type
number or array
- rate¶
determines the rate at which activity increments toward either
max_val
(variable
is positive) ormin_val
(ifvariable
is negative). If it is a float or has a single element, it is applied to all elements ofvariable
; if it has more than one element, each element is applied to the corresponding element ofvariable
. Serves as MULTIPLICATIVE_PARAM for modulation offunction
.- Type
float or 1d array in interval [0,1]
- decay¶
determines the rate of at which activity decays toward
rest
(similary to rate in other IntegratorFuncgtions). If it is a float or has a single element, it applies to all elements ofvariable
; if it has more than one element, each element applies to the corresponding element ofvariable
.- Type
float or 1d array
- rest¶
determines the initial value and one toward which value
decays
(similar to bias in other IntegratorFunctions). If it is a float or has a single element, it applies to all elements ofvariable
; if it has more than one element, each element applies to the corresponding element ofvariable
.- Type
float or 1d array
- max_val¶
determines the maximum asymptotic value toward which integration occurs for positive values of
variable
. If it is a float or has a single element, it applies to all elements ofvariable
; if it has more than one element, each element applies to the corresponding element ofvariable
.- Type
float or 1d array
- min_val¶
determines the minimum asymptotic value toward which integration occurs for negative values of
variable
. If it is a float or has a single element, it applies to all elements ofvariable
; if it has more than one element, each element applies to the corresponding element ofvariable
.- Type
float or 1d array
- noise¶
random value added to
variable
in each call tofunction
(seenoise
for details).- Type
float, Function or 1d array
- initializer¶
determines the starting value(s) for integration (i.e., the value(s) to which
previous_value
is set (seeinitializer
for details).- Type
float or 1d array
- previous_value¶
stores previous value with which
variable
is integrated.- Type
1d array : default class_defaults.variable
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _validate_params(request_set, target_set=None, context=None)¶
Check inner dimension (length) of all parameters used for the function
- Insure that for any parameters that are in the Parameters class, designated as function_arg, and
specified by the user with length>1: 1) they all have the same length; 2) if default_variable:
was specified by the user, the parameters all have the same length as that
was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below
- _function(variable=None, context=None, params=None)¶
- Parameters
variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
- Returns
updated value of integral
- Return type
2d array
- class psyneulink.core.components.functions.stateful.integratorfunctions.IntegratorFunction(default_variable=None, rate=None, noise=None, initializer=None, params=None, owner=None, prefs=None, context=None, **kwargs)¶
Base class for Functions that integrate current value of
variable
with its prior value. For most subclasses,variable
can be a single float or an array. If it is an array, each element is integrated independently of the others.Note
If
variable
is an array, for any parameter that is specified as a float its value is applied uniformly to all elements of the relevant term of the integral (e.g.,variable
orprevious_value
, depending on the subclass); for any parameter specified as an array, it must be the same length asvariable
, and it is applied elementwise (Hadarmard) to the relevant term of the integral. If, on initialization, the default_variable is not specified, any parameters specified as an array must be the same length, and the default_variable is assumed to have the same length as those parameters.- Parameters
default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.
initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as
variable
(seeinitializer
for details).rate (float, list or 1d array : default 1.0) – specifies the rate of integration. If it is a list or array, it must be the same length as
variable
(seerate
for details).noise (float, list, array or function : default 0.0) – specifies value added to integral in each call to
function
; if it is a list or array, it must be the same length asvariable
(seenoise
for additional details).time_step_size (float : default 0.0) – determines the timing precision of the integration process
params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner (Component) – component to which to assign the Function.
name (str : default see
name
) – specifies the name of the Function.prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the
PreferenceSet
for the Function (seeprefs
for details).
- variable¶
current input value some portion of which (determined by
rate
) that will be added to the prior value; if it is an array, each element is independently integrated.- Type
number or array
- rate¶
determines the rate of integration. If it is a float or has a single value, it is applied to all elements of
variable
and/orprevious_value
(depending on the subclass); if it has more than one element, each element is applied to the corresponding element ofvariable
and/orprevious_value
.- Type
float or 1d array
- noise¶
value is added to integral in each call to
function
. If noise is a float, it is applied to all elements ofvariable
; if it is an array, it is applied Hadamard (elementwise) to each element ofvariable
. If it is a function, it is executed separately and applied independently to each element ofvariable
.Hint
To generate random noise that varies for every execution and across all elements of an array, a
DistributionFunction
should be used, that generates a new value on each execution. If noise is specified as a float, a function with a fixed output, or an array of either of these, then noise is simply an offset that is the same across all elements and executions.- Type
float, array or Function
- initializer¶
determines the starting value(s) for integration (i.e., the value(s) to which
previous_value
is set. Ifvariable
is a list or array, and initializer is a float or has a single element, it is applied to each element ofprevious_value
. If initializer is a list or array, each element is applied to the corresponding element ofprevious_value
.- Type
float or 1d array
- name¶
the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).
- Type
str
- prefs¶
the
PreferenceSet
for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned usingclassPreferences
defined in __init__.py (see Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _validate_params(request_set, target_set=None, context=None)¶
Check inner dimension (length) of all parameters used for the function
- Insure that for any parameters that are in the Parameters class, designated as function_arg, and
specified by the user with length>1: 1) they all have the same length; 2) if default_variable:
was specified by the user, the parameters all have the same length as that
was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below
- _instantiate_attributes_before_function(function=None, context=None)¶
Insure inner dimension of default_variable matches the length of any parameters that have len>1
- _EWMA_filter(previous_value, rate, variable)¶
Return exponentially weighted moving average (EWMA) of a variable.
- _logistic(variable, gain, bias)¶
Return logistic transform of variable