-
Notifications
You must be signed in to change notification settings - Fork 17
/
plot_calculations.r
50 lines (41 loc) · 2.26 KB
/
plot_calculations.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
## Auxiliary routines to compute all data for plotting the figures
## compute.fn must be a function that takes n.list, alpha, mu, eps and
## computes a data frame with all shadowed parameters and the 1-bit
## extractor seeds.
gen.plot.data <- function(n.list, alpha.list, mu.list, eps.list,
compute.fn) {
data.n.mu.alpha.eps <- do.call(rbind, lapply(eps.list, function(.eps) {
cat("eps: ", .eps, "\n")
do.call(rbind, lapply(alpha.list, function(.alpha) {
do.call(rbind, lapply(mu.list,
function(.mu) {
cat(" -> mu: ", .mu, "\n")
compute.fn(n.list, .alpha, .mu, .eps) })) })) }))
data.n.mu.alpha.eps$m <- data.n.mu.alpha.eps$alpha*data.n.mu.alpha.eps$mu*data.n.mu.alpha.eps$n
data.n.mu.alpha.eps$alpha <- as.factor(data.n.mu.alpha.eps$alpha)
data.n.mu.alpha.eps$total.seed.2e <- data.n.mu.alpha.eps$seed.length**2
data.n.mu.alpha.eps$seed.ratio <- data.n.mu.alpha.eps$n/(data.n.mu.alpha.eps$total.seed.2e)
data.n.mu.alpha.eps$seed.inv.ratio <- 1/data.n.mu.alpha.eps$seed.ratio
data.n.mu.alpha.eps$seed.ratio.m <- data.n.mu.alpha.eps$m/(data.n.mu.alpha.eps$total.seed.2e)
data.n.mu.alpha.eps$seed.inv.ratio.m <- 1/data.n.mu.alpha.eps$seed.ratio.m
data.n.mu.alpha.eps$extracted.bits <- data.n.mu.alpha.eps$m - data.n.mu.alpha.eps$total.seed.2e
data.n.mu.alpha.eps$mu <- as.factor(data.n.mu.alpha.eps$mu)
data.n.mu.alpha.eps$eps <- as.factor(data.n.mu.alpha.eps$eps)
return(data.n.mu.alpha.eps)
}
## Compute the break-even point from which onwards we produce more randomness
## than we require for the seed.
## Input: data matrix produced by gen.plot.data where alpha does _NOT_ vary.
compute.breaks.alpha <- function(data.n.mu.eps, eps.list) {
dat.breaks <- do.call(rbind, lapply(eps.list, function(.eps) {
data.frame(mu=mu.list, eps=.eps,
break.even=sapply(mu.list,
function(.mu) {
cat("eps: " , .eps, ", mu: ", .mu, "\n")
dat.subs <- subset(data.n.mu.eps, mu==.mu)
dat.subs <- subset(dat.subs, eps==.eps)
idx <- sum(dat.subs$seed.inv.ratio.m > 1)+1
return(dat.subs[idx,]$n)
})) }))
return(dat.breaks)
}