# Autocorrelated random field generation

Problem is related with my other question

So, generate exponentially correlated row $$𝑥_{0,0},𝑥_{1,0}...𝑥_{𝑛,0}$$ and starting from 𝑥0,0 there will be a correlated column $$𝑥_{0,1},𝑥_{0,2}...𝑥_{0,n}$$.

During generation we used a correlation $$𝜌=𝑒𝑥𝑝(−Δ𝜏/𝜉)$$. And $$𝑥_{𝑗,0}=\sqrt{1−𝜌^2}Rand[NormalDistribution[𝜇,𝜎]]+𝜌 𝑥_{𝑗−1,0}$$

So...During 2 dimensions it should be $$𝜌=𝑒𝑥𝑝(−Δ𝜏𝑥/𝜉𝑥−Δ𝜏𝑦/𝜉𝑦)$$. And in isotropic space $$𝜌=𝑒𝑥𝑝(−2Δ𝜏/𝜉)$$.

But how to generate $$𝑥_{1,1}$$ correctly with this $$𝜌$$? This one with square mean looks absolutely wrong: $$𝑥_{1,1}=\sqrt{1−𝜌2}Rand[NormalDistribution[𝜇,𝜎]]+𝜌\sqrt{𝑥_{1,0} 𝑥_{0,1}}$$

Tried to generate with arithmetic mean: $$𝑥_{1,1}=\sqrt{1−𝜌2}Rand[NormalDistribution[𝜇,𝜎]]+𝜌(𝑥_{1,0}+ 𝑥_{0,1})/2$$ But it look not correlated in Y direction... Any way to make it better?

my code:

μ = 0; σ = 1; ξ = 10; τ = 1; l = {{0, 0,
RandomVariate[NormalDistribution[μ, σ],
1][[1]]}}; size = 100; ρ = E^(-(
Abs[τ]/ξ)); ρ2 = E^(-2 Abs[τ]/ξ);
For[j = 1, j < size, j++,
Subscript[x, 0] = {l[[1, 3]]};
Subscript[x,
j] = ρ2 Subscript[x, j - 1][[1]] +
Sqrt[1 - ρ2^2]
RandomVariate[NormalDistribution[μ, σ], 1];
AppendTo[l, {j, 0, Subscript[x, j][[1]]}]];

For[i = 1, i < size, i++,
Subscript[x,
0] = ρ2 l[[1 + size (i - 1), 3]] +
Sqrt[1 - ρ2^2]
RandomVariate[NormalDistribution[μ, σ], 1];
AppendTo[l, {0, i, Subscript[x, 0][[1]]}];
For[j = 1, j < size, j++,
Subscript[x,
j] = ρ2 (Subscript[x, j - 1][[1]] + l[[size i + j, 3]])/2 +
Sqrt[1 - ρ2^2]
RandomVariate[NormalDistribution[μ, σ], 1];
AppendTo[l, {j, i, Subscript[x, j][[1]]}]]];
ListContourPlot[l]
ListPlot3D[l]

• The standard way to generate correlated noise, is to: 1) Compute the autocorrelation function; 2) Fourier Transform this to get the Power spectrum; 3) Generate independent random numbers; 4) scale by the sqrt of the Power spectrum; 5) Fourier transform; 6) Verify that you have the autocorrelation function you wanted. (This will work in any number of dimensions) – mikado Mar 9 '19 at 22:24
• @mikado: Not sure where I heard this many years ago: "We must love standards because we have so many of them." For me the standard way for this problem is to generate random samples directly from a multivariate normal with the desired covariance structure. – JimB Mar 9 '19 at 23:03
• @JimB if I want to generate (say) a 1000x1000 image of correlated noise, my method involves generating 10^6 random samples, weighting each one with a simple function and 2D FFT (quick). Yours involves generating a 10^6 x 10^6 covariance matrix. Mathematica would struggle to generate the resulting random vector. – mikado Mar 9 '19 at 23:37
• @mikado Yep, there would be a bit of a struggle. My weak/feeble defense is that I didn't see the OP state any size requirements. – JimB Mar 9 '19 at 23:42

n = 100;