Offset#

class Offset(input=None, offset=0, index=0, **kwargs)[source]#

Bases: object

A class for adding a scalar to one element of an input array. In practice, this can be used to “shift” or “offset” the “value” of one particular stimulus, for example to represent a consistent bias for (or against) that stimulus.

Parameters:
inputarray_like

The input value. The stimulus representation (vector).

offsetfloat

The value to be added to one element of the input.

indexint

The index of the element of the input vector to which the offset should be added.

**kwargsdict, optional

Additional keyword arguments.

Examples

>>> vals = np.array([2.1, 1.1])
>>> offsetter = Offset(input = vals, offset = 1.33, index = 0)
>>> offsetter.compute()
array([3.43, 1.1])
compute()[source]#

Add the offset to the requested input element.

Returns:
numpy.ndarray

The stimulus representation (vector) with offset added to the requested element.