bandit_posterior: bandit posterior

Description Usage Arguments Value See Also Examples

View source: R/bandit_posterior.R

Description

Utility function for calculating the posterior probability of each machine being "good" in two armed bandit problem. Calculated result is based on observed win loss data, prior belief about which machine is good and the probability of the good and bad machine paying out.

Usage

1
2
3
4
5
bandit_posterior(
  data,
  prior = c(m1_good = 0.5, m2_good = 0.5),
  win_probs = c(good = 1/2, bad = 1/3)
)

Arguments

data

data frame containing win loss data

prior

prior vector containing the probabilities of Machine 1 and Machine 2 being good, defaults to 0.5 and 0.5 respectively.

win_probs

vector containing the probabilities of winning on the good and bad machine respectively.

Value

A vector containing the posterior probability of Machine 1 and Machine 2 being the good machine.

See Also

bandit_sim to generate data and plot_bandit_posterior to visualize.

Examples

1
2
3
4
data = data.frame(machine = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), 
                  outcome = c("W", "L", "W", "L", "L", "W", "L", "L", "L", "W"))
bandit_posterior(data)
plot_bandit_posterior(data)

StatsWithR/statsr documentation built on Jan. 24, 2021, 10:12 a.m.