# NOT RUN {
#########################################################################80
## rplba1
#########################################################################80
# }
# NOT RUN {
n <- 2^20; n
A <- 1.5
b <- 2.7
mean_v <- c(3.3, 2.2)
mean_w <- c(1.5, 3.7)
sd_v <- c(1, 1)
rD <- .3
swt <- .5
t0 <- .08
ncore <- 12
dat1 <- rplba1R(n, A, b, t0, mean_v, mean_w, sd_v, rD, swt)
dat2 <- rplba1(n, A, b, t0, mean_v, mean_w, sd_v, rD, swt, ncore)
dat3 <- ppda::rplba1(n, A, b, t0, mean_v, mean_w, sd_v, rD, swt)
dat1r1 <- dat1[dat1[, 2] == 1, 1]
dat1r2 <- dat1[dat1[, 2] == 2, 1]
dat2r1 <- dat2[dat2[, 2] == 1, 1]
dat2r2 <- dat2[dat2[, 2] == 2, 1]
dat3r1 <- dat3[dat3[, 2] == 1, 1]
dat3r2 <- dat3[dat3[, 2] == 2, 1]
xlim <- c(0, 3)
## Check if two methods produce SPDF overlaping with each other
par(mfrow = c(4, 2), mar = c(4, 5.3, 0.82, 1))
hist(dat1r1, breaks = "fd", freq = FALSE, main = "Choice1 R", xlim = xlim)
hist(dat1r2, breaks = "fd", freq = FALSE, main = "Choice2 R", xlim = xlim)
hist(dat2r1, breaks = "fd", freq = FALSE, main = "Choice1 C++", xlim = xlim)
hist(dat2r2, breaks = "fd", freq = FALSE, main = "Choice2 C++", xlim = xlim)
hist(dat3r1, breaks = "fd", freq = FALSE, main = "Choice1 GPU", xlim = xlim)
hist(dat3r2, breaks = "fd", freq = FALSE, main = "Choice2 GPU", xlim = xlim)
par(mfrow = c(1, 2))
hist(dat1r1, breaks = "fd", freq = FALSE, main = "Choice1 R, C++, & GPU",
xlim = xlim, ylim = c(0, 3))
hist(dat2r1, breaks = "fd", freq = FALSE, add = TRUE, col = "lightblue")
hist(dat3r1, breaks = "fd", freq = FALSE, add = TRUE, col = "lightgreen")
hist(dat1r2, breaks = "fd", freq = FALSE, main = "Choice2 R, C++ & GPU",
xlim = xlim, ylim = c(0, 3))
hist(dat2r2, breaks = "fd", freq = FALSE, add = TRUE, col = "lightblue")
hist(dat3r2, breaks = "fd", freq = FALSE, add = TRUE, col = "lightgreen")
# }
# NOT RUN {
#############20
## rplba2 ##
#############20
# }
# NOT RUN {
n <- 2^15
ncore <- 4
A <- c(1.5, 1.5)
b <- c(2.7, 2.7)
mean_v <- c(3.3, 2.2)
mean_w <- c(1.5, 3.7)
sd_v <- c(1, 1)
sd_w <- c(1, 1)
rD <- .3
swt <- .5
t0 <- .08
dat1 <- rplba2R(n, A, b, t0, mean_v, mean_w, sd_v, sd_w, rD, swt)
dat2 <- rplba2(n, A, b, t0, mean_v, mean_w, sd_v, sd_w, rD, swt, ncore)
dat3 <- rplba2(n, A, b, t0, mean_v, mean_w, sd_v, sd_w, rD, swt)
dat4 <- rplba2_test(n, A, b, t0, mean_v, mean_w, sd_v, sd_w, rD, swt)
dat1r1 <- dat1[dat1[, 2] == 1, 1]
dat1r2 <- dat1[dat1[, 2] == 2, 1]
dat2r1 <- dat2[dat2[, 2] == 1, 1]
dat2r2 <- dat2[dat2[, 2] == 2, 1]
dat3r1 <- dat3[dat3[, 2] == 1, 1]
dat3r2 <- dat3[dat3[, 2] == 2, 1]
dat4r1 <- dat4[dat4[, 2] == 1, 1]
dat4r2 <- dat4[dat4[, 2] == 2, 1]
wesanderson::wes_palette("Royal1")
palettes <- wesanderson::wes_palettes$GrandBudapest
palettes2 <- wesanderson::wes_palettes$GrandBudapest2
xlim <- c(0, 3)
## Check if two methods produce SPDF overlaping with each other
par(mfrow = c(4, 2), mar = c(4, 5.3, 0.82, 1))
hist(dat1r1, breaks = "fd", freq = FALSE, main = "Choice1 R", xlim = xlim)
hist(dat1r2, breaks = "fd", freq = FALSE, main = "Choice2 R", xlim = xlim)
hist(dat2r1, breaks = "fd", freq = FALSE, main = "Choice1 C++", xlim = xlim)
hist(dat2r2, breaks = "fd", freq = FALSE, main = "Choice2 C++", xlim = xlim)
hist(dat3r1, breaks = "fd", freq = FALSE, main = "Choice1 GPU", xlim = xlim)
hist(dat3r2, breaks = "fd", freq = FALSE, main = "Choice2 GPU", xlim = xlim)
hist(dat4r1, breaks = "fd", freq = FALSE, main = "Choice1 test", xlim = xlim)
hist(dat4r2, breaks = "fd", freq = FALSE, main = "Choice2 test", xlim = xlim)
par(mfrow = c(1, 2))
hist(dat1r1, breaks = "fd", freq = FALSE, main = "Choice1 R, C++, & GPU",
xlim = xlim, ylim = c(0, 3))
hist(dat2r1, breaks = "fd", freq = FALSE, add = TRUE, col = palettes[1])
hist(dat3r1, breaks = "fd", freq = FALSE, add = TRUE, col = palettes[2])
hist(dat4r1, breaks = "fd", freq = FALSE, add = TRUE, col = palettes[4])
hist(dat1r2, breaks = "fd", freq = FALSE, main = "Choice2 R, C++ & GPU",
xlim = xlim, ylim = c(0, 3))
hist(dat2r2, breaks = "fd", freq = FALSE, add = TRUE, col = palettes2[1])
hist(dat3r2, breaks = "fd", freq = FALSE, add = TRUE, col = palettes2[2])
hist(dat4r2, breaks = "fd", freq = FALSE, add = TRUE, col = palettes2[3])
# }
Run the code above in your browser using DataLab