The autoregressive model captures the autocorrelation between the sample signals from the same access point. Using this model to calculate the distribution of the average of n correlated samples. This is done in a WiFi location system. Please make corrections to the code below. I'm a newbie and would really appreciated your assistance.
Thanks!
static void Calculate_P(int x,int y)
{
double a, b = 0, c = 0;
double h = 0;
for(int i = 0; i <= 1; i++)
{
for(int j = 0; j <= 3; j++)
{
for(int k = 0; k <= 3; k++)
{
h += GlobalVariable.Str[i, j, k];
}
h /= 4;
GlobalVariable.aves[i, j] = h;
}
}
for(int i = 0; i <= 1; i++)
{
for(int j = 0; j <= 3; j++)
{
for(int k = 0; k <= 2; k++)
{
b += (GlobalVariable.Str[i, j, k] - GlobalVariable.aves[i, j]) * (GlobalVariable.Str[i, j, k + 1 ] - GlobalVariable.aves[i, j]);
}
for(int k = 0; k <= 3; k++)
{
c += (GlobalVariable.Str[i, j, k] - GlobalVariable.aves[i, j]) * (GlobalVariable.Str[i, j, k] - GlobalVariable.aves[i, j]);
}
a = b / c;
Console.WriteLine("location{0},AP{1}
Autocorrelation coefficient:{2} ", i + 1, j + 1, a);
}
}
}