# NOT RUN {
set.seed(203490L)
V=crossprod(matrix(rnorm(25),5))
VI=solve(V)
L=t(chol(V))
chibarsq=replicate(1e3L, -2*quadprog::solve.QP(VI, VI%*%(L%*%rnorm(5)),
diag(1,5), rep(0,5))[['value']] )
chibarsq=sort(chibarsq)
p=pchibarsq(chibarsq, V)
# }
# NOT RUN {
plot(ecdf(chibarsq))
lines(chibarsq, p, col=4, lwd=3, lty=3)
# }
# NOT RUN {
mean(chibarsq); mean(chibarsq^2)
mchibarsq(V)
# }
Run the code above in your browser using DataLab