Generating strongly correlated data for numerical experiments

Since real-life traffic traces are not readily available, for my simulations, I generate traffic traces as follows:

trace = []
nom = sample(collect(0.5:0.2,0.9), WeightVec([0.3,0.4,0.3]))
for i=1:100
  push!(trace, nom + rand(Normal(0,nom)))
end

I repeat this process for all commodities (c\in C) in the network thereby obtaining unique traces for every commodity. However, I would now like to generate strongly correlated traces. Is there a package in Julia that could help me generate such strongly correlated traces?

It is not clear what you are trying to do — is dnom a typo, or a variable that you did not initialize?

In any case, if you want series with correlated noise, you should just draw correlated variables (eg using a multivariate normal with non-diagonal variance matrix, or some more sophisticated hierarchical arrangement) and use them.

1 Like

Sorry about the typo. I donot want a temporally correlated trace but spatially correlated traces. Assuming we have two commodities c1 and c2, I want their respective traces to be strongly correlated with each other.

The following code generates two series that are strongly correlated with one another, but serially uncorrelated. Is that what you have in mind?

using Plots
T = 100
Sig = [1 0.9; 0.9 1]
P = chol(Sig)
x = randn(T,2)*P
x = x .+ [-2.0 2.0]
show(cov(x))
plot(x)
2 Likes

Thanks a lot. This is exactly what I wanted for my simulations.