-
Notifications
You must be signed in to change notification settings - Fork 0
/
Testing-simulated-A-B.R
35 lines (26 loc) · 1.08 KB
/
Testing-simulated-A-B.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Load the required libraries
library(tidyverse)
# Set the random seed for reproducibility
set.seed(123)
# Define the parameters for the Beta distributions (prior beliefs)
prior_a <- 50 # Shape parameter for Version A
prior_b <- 50 # Shape parameter for Version B
# Simulate the number of visitors for each version
n_visitors_a <- 1000
n_visitors_b <- 1000
# Simulate conversion data for Version A
conversion_data_a <- rbeta(n_visitors_a, shape1 = prior_a, shape2 = prior_b)
# Simulate conversion data for Version B
conversion_data_b <- rbeta(n_visitors_b, shape1 = prior_a, shape2 = prior_b)
# Create data frames for each version
data_a <- data.frame(Version = "A", Conversion = conversion_data_a)
data_b <- data.frame(Version = "B", Conversion = conversion_data_b)
# Combine the data frames
simulated_data <- bind_rows(data_a, data_b)
# Print the first few rows of the simulated data
head(simulated_data)
# Plot the simulated data
ggplot(simulated_data, aes(x = Version, y = Conversion)) +
geom_boxplot(fill = "lightblue") +
labs(x = "Version", y = "Conversion Rate") +
theme_minimal()