[This article was first published on Wiekvoet
, and kindly contributed to R-bloggers
]. (You can report issue about the content on this page here
Want to share your content on R-bloggers? click here
if you have a blog, or here
if you don't.
In my previous post I tried building Williams designs in R. Since that code was running a bit slow, this was an ideal test for Julia. Big enough to be at least slightly realistic, small enough that it is doable.
I am very impressed. Almost twenty fold speed increase, even though this was the best I could do in R, the most naive way possible in Julia.
R Julia Ratio
Double Williams design 4, 100 times 3.97 sec 0.212 sec 0.053
Williams design 5, 10 times 289.5 sec 18.54 sec 0.064
I’d surely love to use Julia more. For instance, if I could port some of the algorithm’s of Professor Ng Machine Learning class to Julia? I don’t think it is possible yet, but what is not, may come.
t0 = 0
t0 = t0 + @elapsed $ex
println(“julia,”, $name, “,”, t0)
desmat = zeros(Uint8,nrow,ncol)
desmat[1,1:ncol] = [1:ncol]
for i = [1:ncol]
desmat[2*i-1,1] = i
carover = zeros(Uint8,ncol,ncol)
for i = 1:(ncol-1)
carover[i,i+1] = 1
count = 0
addpoint( desmat , carover,count)
length(matin) – nnz(matin)
nrow, ncol = size(matin)
for row = 1:nrow
for col = 1:ncol
if matin[row,col] == 0
return row, col
if nnz(desmat) == length(desmat)
row,col = first0(desmat)
for i = [1:size(desmat,2)]
if numzero(desmat[row,:]-i) == 0
if numzero(desmat[:,col]-i) < 2
if carover[desmat[row,col-1],i] < 2
if (col !=2) | (desmat[row,1] != desmat[row-1,1]) | (desmat[row-1,col] < i)
count = addpoint(desmat,carover,count)
@timeit gendesign(4) “design 4 ” 100
@timeit gendesign(5) “design 5 ” 10
Both designs were created using the same script. If you ask an even number of design points using the odd algorithm, then this will work. You just get a design with double the rows, carry over balanced, every treatment equally often in each row and each column.