# Evaluate optimal holdout set size for a range of values of k1, and compute
# derivative
N=10000;
k1=seq(0.1,0.5,length=20)
A=3; B=1.5; C=0.15; theta=c(A,B,C)
nstar=optimal_holdout_size(N,k1,theta)
grad_nstar=grad_nstar_powerlaw(N,k1,theta)
plot(0,type="n",ylim=c(-2000,500),xlim=range(k1),xlab=expression("k"[1]),
ylab="Optimal holdout set size")
lines(nstar$k1,nstar$size,col="black")
lines(nstar$k1,grad_nstar[,2],col="red")
legend("bottomright",c(expression("n"["*"]),
expression(paste(partialdiff[k1],"n"["*"]))),
col=c("black","red"),lty=1)
Run the code above in your browser using DataLab