Calculate balancing weight scores.
Calculates the inverse probability score of pulling arms, given the actions taken and the true probabilities of each arm being chosen.
calculate_balwts(ws, probs)
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.A matrix or array containing the inverse probability score of pulling arms.
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)
Useful links