Click here to Skip to main content
15,920,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!

C#
static void Calculate_P(int x,int y)
        {
            double a, b = 0, c = 0;
            double h = 0;
            //calculate each location for each AP
            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);
                }
            }
        }
Posted
Updated 12-Dec-09 8:52am
v2

1 solution

what is the problem? And where in the code does it occur?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900