Generate line function data with noise

I would like to assess one dimension reduction method on simulation data. Besides totally random data, I want to simulate a partial random dataset. Right now I can think of one method to generate such data

rand2 = collect(1:85)
for m in 1:20
v = []
for i in 1:85
    ai = i/m
    bi = rand(Float64)
    pi = i/85
    push!(v, ai+bi*pi)
end
rand2=hcat(rand2,v)
end
rand2 =rand2[:, (1:end) .!= 1]

Is there a better way to generate partially random data? Like data points follow line functions but there are noises. Thanks in advance!

List comprehensions provide this functionality quite nicely. You can easily generate a 2-dimensional matrix by specifying two dimensions to loop over (iterating over the ith row and jth column):

rand2 = [i*(1/j+rand()/85) for i=1:85, j=1:20]

This doesn’t work so well when one value in the matrix depends on the value of another, but that’s not the case here.