I am trying to take numbers from two intervals in Julia. The problem is the following, I am trying to create concentric circles and I need to generate vectors of dimension equal to 15 filled with numbers taken from each circle. The code is:
rmax = 5
ra = fill(0.0,1,rmax)
for i=1:rmax-1
ra[:,i].=rad/i
ra[:,rmax].= 0
end
for i=1:3
ptset = Any[]
for j=1:200
yt= 0
yt= rand(Truncated(Normal(0, 1), -ra[i], ra[i] ))
if `-ra[(i+1)] < yt <= -ra[i] || ra[(i+1)] <= yt < ra[i]`
push!(ptset,yt)
if length(ptset) == 15
break
end
end
end
end
Here I try to take elements that fulfill one of the two conditions -ra[(i+1)] < yt <= -ra[i] or ra[(i+1)] <= yt < ra[i], i.e. I would like to generate a vector with positive and negative numbers. I used the operator || but it seems to take only the positive part. I am new in Julia and I am not sure how to take the elements from both parts of the interval. Does anyone has a hit on how to do it?. Thanks in advance
Aucun commentaire:
Enregistrer un commentaire