# Would the ratio of Autocorrelation value and autocorrelation of noise for different data types be different? in Matlab

Considering a model of the form:

$y[n] = x[n] + noise[n]$ and

$y[n] = u[n] + noise[n]$

where the term noise represents Additive White Gaussian Noise of variance $\sigma^2_{noise}$. I want to understand if there is any difference in the value of the terms: $\sigma^2_x/\sigma^2_{noise}$ and $\sigma^2_u/\sigma^2_{noise}$ by varying the noise level.

$x$ represents a signal generated from Gaussian distribution whose variance is $\sigma^2_x$. In Matlab, I have used the command rand() to generate $x$.

$u$ represents another signal taking values zero or 1 having variance $\sigma^2_u$. In Matlab, I have used rand()>0.5 to generate thie binary valued data.

Based on my understanding the numerator in the ratio is the autocorrelation of the data mathematically expressed as $E[\mathbf{x}[n]\mathbf{x}[n]^T]$ and $E[\mathbf{u}[n]\mathbf{u}[n]^T]$. Why are these terms giving same result?

In most papers, the variance of the data irrespective of whether it takes numeric or symbols is considered to be 1.

Question1) Is my approach of implementing the ratio correct? I cannot understand what the value of $\sigma^2_x$ and $\sigma^2_u$ should be in practice. Implementing this way would give the same value for the ratio for both the different kinds of data $x$ and $u$. Would the auto correlation for numeric values x and binary data u be the same value?

Question2) If the ratio is the same then what is the need for using binary signal?

N = 128;
var_x =1;
var_u = 1;
signal_x = rand(1,N);
signal_u = rand(1,N)>=0.5; % this creates 0/1 data
noise = 0;
index = 1;
for noise = 0:5:30
noise_var  = 10^(-noise/10);
ratio_x(index)= 10*log10(var_x/noise_var); %in dB
ratio_u(index)= 10*log10(var_u/noise_var);
index = index+1;
end

• What is $x$, what is $u$? Could you write down the model for your data? Your code is not likely to work, starting index i with 0, and noise does not seem to change Nov 9 '17 at 20:27
• @LaurentDuval: thank you for pointing out the mistakes. I have fixed them. Nov 9 '17 at 20:40
• A good start. However, ratio_x(0) won't work Nov 9 '17 at 21:03
• @LaurentDuval: I am not getting any error but all the values in the array ratio_x and ratio_u are zero Nov 9 '17 at 21:54
• Weird, which matlab version are you using? Second, nothing changes inside the loop, and because of i = 0:5:30some inner indices yield zero values Nov 9 '17 at 22:26

I am not really sure what you want to do so please comment and I will modify my answer.

## The case that $x$ and $u$ seems statistically identical is that $x$ is standard Gaussian random variable and $u$ has $\pm 1$ values.

Use your notations, $x$ is Gaussian random variable with zero mean and unit variance (deducted from the fact that you used the standard rand function, even though the randn() function must be used for Gaussian pdf).

Let's stay with real $x$ for the sake of simplicity :

$$p(x) = \frac{1}{\sqrt{2\pi}\sigma}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)$$

with $\mathbb{E}[x] = \mu = 0 \textrm{ and } \mathrm{var}(x) = \sigma^2 = \mathbb{E}[x^2] = 1$.

Thus the probabilites $\mathrm{Pr}(x >= 0) = \mathrm{Pr}(x < 0) = 0.5$.

The processed data $u = 1 \textrm{ if } x \ge 0 \textrm{ and } u=-1 \textrm{ otherwise}$. Thus $\mathbb{E}[u] = (1) \times \mathrm{Pr}(x >= 0) + (-1) \times \mathrm{Pr}(x < 0) = 0.$

Then $\mathrm{var}(u) = \mathbb{E}[(u - \mathbb{E}[u])^2] = \mathbb{E}[u^2] = (1)^2 \times \mathrm{Pr}(x >= 0) + (-1)^2 \times \mathrm{Pr}(x < 0) = 1$.

The means and variances are just coincidentally identical.

MATLAB/Octave code

octave:6> N = 65536;
octave:7> x=randn(1,N);
octave:8> u=2*(randn(1,N)>0) - 1;
octave:9> var(x)
ans =  1.0020
octave:10> var(u)
ans =  1.0000


## The case of OP question $x$ is (0,1)-uniform (by rand()) and $u$ is binary:

$\mathrm{Pr}(x >= 0.5) = \mathrm{Pr}(x < 0.5) = 0.5$.

$\mathbb{E}[x] = 0.5$

$\mathrm{var}(x) = \int_0^1 (x-0.5)^2 \mathrm{d}x = \frac{2}{3}\times 0.5^3 \approx 0.8$

The processed data $u = 1 \textrm{ if } x \ge 0.5 \textrm{ and } u=0 \textrm{ otherwise}$. Thus $\mathbb{E}[u] = (1) \times \mathrm{Pr}(x >= 0.5) + 0 \times \mathrm{Pr}(x < 0.5) = 0.5$.

$\mathrm{var}(u) = \mathbb{E}[(u - 0.5)^2] = (1 - 0.5)^2 \times \mathrm{Pr}(x >= 0.5) + (0 - 0.5)^2 \times \mathrm{Pr}(x < 0.5) = 0.25$

MATLAB/Octave code

octave:13> N = 65536;
octave:14> x=rand(1,N);
octave:15> u=rand(1,N)>0.5;
octave:16> var(x)
ans =  0.083424
octave:17> var(u)
ans =  0.25000


The variances are different !!!

• Thank you!! this analysis is exactly what I wanted and yes, $x$ is A Gaussian random variable. I never have found in any text which explains the expectation in this way. One last question, for multiple level symbols say the symbols denoting QAM modulation, the mean of the symbols come to be zero. Example, for 64 QAM the symbols would be: $\{\pm3,\pm5,\pm7,\pm1\}$ ( if I remember correctly) the mean would be zero. So, is your analysis applicable to this case yielding the variance of symbols = 1? Nov 11 '17 at 0:53
• It depends. The set of (unnormalized) quantized values $\{\pm 1, \pm 3, \pm 5, \pm 7\}$ are chosen so that we have unit variance if they are equally probable. If you choose uniform step size for quantization for a Gaussian $x$, these values are not necessarily equally probable. You can choose either non-uniform step size, or code with other quantized values different from $\{\pm 1, \pm 3, \pm 5, \pm 7\}$ Nov 11 '17 at 8:09
• Great that you got it. And sorry that I know nothing about Constant Modulus Algorithm to answer your new question. Nov 11 '17 at 20:44