How to generate random numbers from a Gaussian distribution with a squared exponential autocorrelation function?

331 Views Asked by At

I need a simple way of generating a list of random numbers from a Gaussian distribution (with mean $\mu$ and standard deviation $\sigma$), which must satisfy the following (squared exponential) autocorrelation function:

$$R=\exp\left(-\left(\frac{d}{l_r}\right)^2\right)$$

where $d$ is the distance between two points and $l_r$ is the correlation length.

As a practical example, I want to assign a random material strength along the length of a metal specimen at a number of consecutive points ($x_1$, $x_2$, $x_3$, ...), where these points are $d=1$ apart. For $\mu=100$, $\sigma=10$, and $l_r=5$, I would need to generate a list of random numbers that satisfies the above condition (e.g. 96, 101, 87, 102, 111, 90, 80, 105, ...).

I understand that the values of two neighbouring points are highly correlated, and for two remote points the values are essentially independent.

Is there a straightforward way to do this using a simple VBA code, for example?

1

There are 1 best solutions below

5
On BEST ANSWER

My understanding of your question is that you are trying to generate two random variables $Y_{1}$ and $Y_{2}$ such that $(Y_{1},Y_{2})$ has bivariate normal distribution with mean $(\mu_{1},\mu_{2})$ and variance-covariance matrix $\left[\begin{array}{cc}\sigma_{1}^{2}&\rho\sigma_{1}\sigma_{2}\\\rho\sigma_{1}\sigma_{2}&\sigma_{2}^{2}\end{array}\right]$. (This is one of your pairs. Well, for $\mu_{1}=\mu_{2}=\mu$ and $\sigma_{1}=\sigma_{2}=\sigma$.)

To do this, you can use property of bivariate normal (see the part with "To derive the bivariate normal probability function"), where for $X_{1}$ and $X_{2}$ such that $(X_{1},X_{2})$ has bivariate normal with mean $(0,0)$ and variance-covariance matrix equal to $\left[\begin{array}{cc}1&0\\0&1\end{array}\right]$, $$\begin{aligned}Y_{1}=\mu_{1}+\sigma_{11}X_{1}+\sigma_{12}X_{2}\\Y_{2}=\mu_{2}+\sigma_{21}X_{1}+\sigma_{22}X_{2}\end{aligned}$$ has bivariate normal distribution with mean $(\mu_{1},\mu_{2})$ and variance-covariance matrix $\left[\begin{array}{cc}\sigma_{1}^{2}&\rho\sigma_{1}\sigma_{2}\\\rho\sigma_{1}\sigma_{2}&\sigma_{2}^{2}\end{array}\right]$, where $$\begin{aligned}\sigma_{1}^{2}&=\sigma_{11}^{2}+\sigma_{12}^{2}\\\sigma_{2}^{2}&=\sigma_{21}^{2}+\sigma_{22}^{2}\\\rho&=\frac{\sigma_{11}\sigma_{21}+\sigma_{12}\sigma_{22}}{\sigma_{1}\sigma_{2}}\end{aligned}$$

Generating standard multivariate normal in excel is done via

=NORMINV(RAND(); 0;1)
You need to set $\mu_{1}=\mu_{2}=100$. To get your $\sigma=10$ for both variables and $\rho=R$, you need to solve system of $3$ equations above in $4$ unknowns $\sigma_{11}$, $\sigma_{21}$, $\sigma_{21}$ and $\sigma_{22}$. Asking Mathametica to do so (and then confirming the solution)
eq1 := 100 == s11^2 + s12^2;
eq2 := 100 == s21^2 + s22^2;
eq3 := R == (s11*s21 + s12*s22)/Sqrt[s11^2 + s12^2]/
    Sqrt[s21^2 + s22^2];
eq4 := s22 == 1;
eq := {eq1, eq2, eq3, eq4};
s = FullSimplify[Solve[eq, {s11, s12, s21, s22}]];
Simplify[eq /. s[[2]] /. R -> 1/2]
s[[2]]
gives $$\begin{aligned} s_{11}&=\sqrt{1 + 98 R^2 - 6\sqrt {11}\sqrt {R^2 - R^4}}\\ s_{12}&=\sqrt{99 - 98 R^2 + 6\sqrt {11}\sqrt {R^2 - R^4}}\\ s_{21}&=-\frac{3s_ {11}s_ {12}(33-66R^2+98\sqrt{11}\sqrt{R^2-R^4})} {99+10000R^2(R^2-1)}\\ s_{22}&=1\\ \end{aligned}$$