Skip to contents

Calculates the inverse probability score of pulling arms, given the actions taken and the true probabilities of each arm being chosen.

Usage

calculate_balwts(ws, probs)

Arguments

ws

Integer vector. Indicates which arm was chosen for observations at each time t. Length A. Must not contain NA values.

probs

Numeric matrix or array. True probabilities of each arm being chosen at each time step. Shape [A, K] or [A, A, K]. Must not contain NA values.

Value

A matrix or array containing the inverse probability score of pulling arms.

Examples

set.seed(123)
A <- 5
K <- 3
ws <- sample(1:K, A, replace = TRUE)
probs <- matrix(runif(A * K), nrow = A, ncol = K)
balwts <- calculate_balwts(ws, probs)