Skip to contents

$$U(R) = {R}^{\gamma}$$

Usage

func_gamma(shown, reward, rownum, params, hidden, ...)

Arguments

shown

Which options shown in this trial.

reward

The feedback received by the agent from the environment at trial(t) following the execution of action(a)

rownum

The trial number

params

Parameters used by the model's internal functions, see params

hidden

All hidden variables within the MDP process belong here.

...

It currently contains the following information; additional information may be added in future package versions.

  • idinfo:

    • subid

    • block

    • trial

  • exinfo: contains information whose column names are specified by the user.

    • Frame

    • RT

    • NetWorth

    • ...

  • behave: includes the following:

    • action: the behavior performed by the human in the given trial.

    • latent: the object updated by the agent in the given trial.

    • simulation: the actual behavior performed by the agent.

    • position: the position of the stimulus on the screen.

  • cue and rsp: Cues and responses within latent learning rules, see behrule

  • state: The state stores the stimuli shown in the current trial—split into components by underscores—and the rewards associated with them.

Value

A List

  • output [NumericVector]

    A numeric value representing the reward after transformation by a utility function.

    By default, it follows Stevens' power law, assuming a power relationship between physical magnitude and perceived utility. The default parameter is gamma = 1, corresponding to a linear transformation.

  • hidden [CharacterVector]

    User-defined internal variables generated by this function. These represent intermediate (latent) states produced during computation, which can be read or modified by other functions in the MDP process.

Body

func_gamma <- function(
    shown,
    reward,
    params,
    ...
){

  list2env(list(...), envir = environment())

  # If you need extra information(...)
  # Column names may be lost(C++), indexes are recommended
  # e.g.
  # Trial  <- idinfo[3]
  # Frame  <- exinfo[1]
  # Action <- behave[1]

  gamma     <-  params[["gamma"]]

  # Stevens' Power Law
  utility <- ((reward >= 0) * 2 - 1) * (abs(reward) ^ gamma)

  return(list(output = utility, hidden = hidden))
}