ContextualLinearBandit | R Documentation |
Contextual Linear Bandit Environment
Contextual Linear Bandit Environment
An R6 class for simulating a contextual linear bandit environment with normally distributed rewards.
- 'initialize(k, d, list_betas, sigma = 0.1, binary_rewards = FALSE)': Constructor. - 'post_initialization()': Loads correct coefficients based on 'sim_id'. - 'get_context(t)': Returns context and sets internal reward vector. - 'get_reward(t, context_common, action)': Returns observed reward for an action.
cramR::NA
-> ContextualLinearBandit
rewards
A vector of rewards for each arm in the current round.
betas
Coefficient matrix of the linear reward model (one column per arm).
sigma
Standard deviation of the Gaussian noise added to rewards.
binary
Logical, indicating whether to convert rewards into binary outcomes.
weights
The latent reward scores before noise and/or binarization.
list_betas
A list of coefficient matrices, one per simulation.
sim_id
Index for selecting which simulation's coefficients to use.
class_name
Name of the class for internal tracking.
new()
ContextualLinearBandit$new( k, d, list_betas, sigma = 0.1, binary_rewards = FALSE )
k
Number of arms
d
Number of features
list_betas
A list of true beta matrices for each simulation
sigma
Standard deviation of Gaussian noise
binary_rewards
Logical, use binary rewards or not
post_initialization()
Set the simulation-specific coefficients for the current simulation.
ContextualLinearBandit$post_initialization()
No return value; modifies the internal state of the object.
get_context()
ContextualLinearBandit$get_context(t)
t
Current time step
A list containing context vector 'X' and arm count 'k'
get_reward()
ContextualLinearBandit$get_reward(t, context_common, action)
t
Current time step
context_common
Context shared across arms
action
Action taken by the policy
A list with reward and optimal arm/reward info
clone()
The objects of this class are cloneable with this method.
ContextualLinearBandit$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.