Skip to contents

The function computes values that are proportinoal to the prior probability for a trajectory defined by two stimuli. The code refers to the two-tap model as described in Goldreich & Tong (2013), given in Formula A08.

Usage

prior_2Tap(x1, x2, time_t, sigma_v)

Arguments

x1

position of tap 1

x2

position of tap 2

time_t

time passing between tap 1 and 2

sigma_v

speed prior (in units of space per time; given as a standard deviation)

Value

values that are proportional to the prior probability for the given trajectory. If x1 and x2 are vectors, a vector of prior probabilities. Note that the returned values are not strictly speaking probabilities because they are not normalized (see article for details or the vignette on the two-tap scenario).

References

Goldreich & Tong, 2013, Frontiers in Psychology

Examples

require(rabBITS)

#XXX Example 1: compute a single point estimate XXX
prior_2Tap(x1=2, x2=4, sigma_v=10, time_t=0.1)
#> [1] 0.05399097

#XXX Example 2: compute a whole vector of combinations of tap 1 and 2 XXX
prior_2Tap(x1=1, x2=c(1:10), sigma_v=10, time_t=0.1)
#>  [1] 3.989423e-01 2.419707e-01 5.399097e-02 4.431848e-03 1.338302e-04
#>  [6] 1.486720e-06 6.075883e-09 9.134720e-12 5.052271e-15 1.027977e-18

#XXX Example 3: plot a prior distribution for combinations of tap 1 and 2 XXX
library(ggplot2)
x1_range <- c(0, 10) #range for taps
x2_range <- c(0, 10)

x1_res <- 100 #resolution for graphs
x2_res <- 100

priorMat <- expand.grid(x1=seq(x1_range[1], x1_range[2], length.out=x1_res),
x2=seq(x2_range[1], x2_range[2], length.out=x2_res))
priorMat$p <- prior_2Tap(x1=priorMat$x1, x2=priorMat$x2, sigma_v=10, time_t=0.1)
ggplot(priorMat, aes(x=x1, y=x2, fill=p)) +
  geom_raster() +
  coord_fixed() +
  ggtitle("prior")