# Generates random data for the dual averaging problem. The problem to # be solved (after executing this method) is # # minimize (1/N) * sum(max(1 - A * x, 0)). # # The data matrix A given at the end of this method is of size N-by-n, # and each individual data term is a single row of this matrix. srand(1); N = 50; n = 500; A = .25 * randn(N, n); x = zeros(n); x[1] = .5; x[2] = .5; y = sign(A * x); flip_indices = (rand(N) .> .95); y[flip_indices] = -y[flip_indices]; A = spdiagm(y) * A; println("The objective value of the x generating the data is ", sum(max(1 - A * x, 0)) / N);