set.seed(824)
std_list = seq(-0.75, 1.00, 0.025)
number_list = sort(rnorm(71, 5, 2))
adjust_list = 10^number_list + rexp(71, 0.001
ShowPoint = function(x, col_, labels_, lx, ly){
index = (x + 0.75) / 0.025 + 1
segments(x, 10, x, adjust_list[index], col = col_, lty = 4, lwd = 2)
segments(-1.25, adjust_list[index], x, adjust_list[index], col = col_, lty = 4, lwd = 2)
text(x, adjust_list[index]*2, labels = labels_)
text(lx, ly, paste0(labels_,"(norm_std=",as.character(x)," num=",as.character(as.integer(adjust_list[index])),")"))
plot(std_list, adjust_list, col = 'blue', type = 'l', xlim = c(-1,1), ylim = c(100, max(adjust_list)), log='y', xlab = 'normalized std', ylab = 'the number of samples', main = 'The histogram of normalized std')
ShowPoint(-0.55, "green", "A", 0.6, 6400)
ShowPoint(-0.25, "orange", "B", 0.6, 1600)
ShowPoint(0.25, "red", "C", 0.6, 400)
ShowPoint(0.95, "purple", "D", 0.6, 100)
library(ggplot2)
library(ggthemes)
y = runif(10^6,0,2)
x = rep(0, 10^6)
for(i in 1:10^6)
x[i] = rnorm(1, 1 - cos(0 - y[i]) * 1.5, sqrt(y[i]/3))
data <- data.frame(x, y)
loc = data.frame(tp = c(-2, 0, 1.8), tr = c(1, 1.4, 1.2))
ggplot(data, aes(x = x, y = y)) +
geom_bin2d(binwidth = 0.01) +
scale_fill_gradient2(low="blue", high = "darkgreen") +
geom_segment(aes(x = tp, y = rep(0,3), xend = tp, yend = tr),
data= loc,
lty = 2,
lwd = 1,
colour = c("tan2","blueviolet","chartreuse")) +
geom_segment(aes(x = rep(-3, 3), y = tr, xend = tp, yend = tr),
data= loc,
lty = 2,
lwd = 1,
colour = c("tan2","blueviolet","chartreuse")) +
geom_text(aes(x = tp, y = tr),
data = loc,
label = c("A(-2,1) num:0","B(0,1.4) num:132","C(1.8,1.2) num:51"),
size = 5,
hjust = 0, nudge_x = 0.05) +
labs(x = 'normalized std', y = 'loss') +
theme_grey()