-
Notifications
You must be signed in to change notification settings - Fork 0
/
figure-timings-meanvar_norm.R
79 lines (78 loc) · 2.57 KB
/
figure-timings-meanvar_norm.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
source("packages.R")
timing.stats <- data.table::fread(
"figure-timings-meanvar_norm-data.csv"
)[N.data<2^19]
timing.stats[, new.pkg := ifelse(
package %in% names(disp.pkg), disp.pkg[package], package)]
timing.stats[, Package := sub("[.]", "\n", new.pkg, perl=TRUE)]
##timing.stats[, Package := sub("[.]|(?<=fpop)::", "\n", package, perl=TRUE)]
(total.minutes <- timing.stats[, sum(seconds_median*seconds_timings) / 60])
timing.stats[, min.loss := min(loss), by=.(case,N.data)]
timing.stats[loss==min.loss, .(N.data, max.segs, case, Package, loss, min.loss)]
timing.stats[loss>min.loss, .(N.data, max.segs, case, Package, loss, min.loss)]
ref.dt <- rbind(
data.table(seconds=1, unit="1 second"),
data.table(seconds=60, unit="1 minute"))
gg <- ggplot()+
scale_color_manual(values=pkg.colors)+
theme_bw()+
theme(panel.spacing=grid::unit(0, "lines"))+
facet_grid(. ~ case, labeller=label_both)+
geom_line(aes(
N.data, loss/N.data, color=Package),
data=timing.stats)+
coord_cartesian(
xlim=c(NA, 1e8))+
scale_x_log10(
"Number of data points to segment (log scale)",
breaks=10^seq(1, 6, by=1))+
scale_y_log10(
"Mean squared error (log scale)")
(dl <- directlabels::direct.label(gg, list(cex=0.6, "last.polygons")))
png("figure-timings-meanvar_norm-loss.png", width=9, height=3.5, units="in", res=200)
print(dl)
dev.off()
gg <- ggplot()+
scale_color_manual(values=pkg.colors)+
scale_fill_manual(values=pkg.colors)+
ggtitle("Normal change in mean and variance")+
theme_bw()+
theme(
legend.position="none",
panel.spacing=grid::unit(0, "lines"))+
facet_grid(. ~ case, labeller=label_both)+
geom_hline(aes(
yintercept=seconds),
data=ref.dt,
color="grey")+
geom_text(aes(
10, seconds, label=unit),
data=ref.dt,
size=3,
hjust=0,
vjust=1.1,
color="grey50")+
directlabels::geom_dl(aes(
N.data, seconds_median, color=Package, label=Package),
data=timing.stats,
method=list(cex=0.6, "last.polygons"))+
geom_ribbon(aes(
N.data, ymin=seconds_min, ymax=seconds_max, fill=Package),
alpha=0.5,
data=timing.stats)+
geom_line(aes(
N.data, seconds_median, color=Package),
data=timing.stats)+
scale_x_log10(
"Number of data points to segment (log scale)",
breaks=10^seq(1, 6, by=1))+
coord_cartesian(
expand=FALSE,
ylim=c(1e-4, 1e3),
xlim=c(8, 5e6))+
scale_y_log10(
"Computation time (seconds, log scale)\nMedian line and min/max band over 5 timings",
breaks=10^seq(-10,10))
png("figure-timings-meanvar_norm.png", width=9, height=3.5, units="in", res=200)
print(gg)
dev.off()