func_gamma: Function: Utility

View source: R/func_gamma.R

func_gammaR Documentation

Function: Utility

Description

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

Usage

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

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)

params

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

...

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 NumericVector of length one representing the subjective value transformed from the objective reward via the utility function.

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(utility)
}

multiRL documentation built on March 31, 2026, 5:06 p.m.