开发者

How to use correlogram to estimate variance?

开发者 https://www.devze.com 2022-12-09 21:24 出处:网络
From a book of computer simulation, I got this two equation. The first is to calculate correlogram, the second is how to use correlogram to estimate variance.

From a book of computer simulation, I got this two equation.

How to use correlogram to estimate variance?

The first is to calculate correlogram, the second is how to use correlogram to estimate variance.

The common approach to estimate variance of observation is often not incorrect in comput开发者_JAVA技巧er simulation because observations are often related.

My question is, the value I calculated from my program is very big, so it could not be correct.

I think because r[k] is going to get near 0 when k gets greater, the second equation will give a quite large value, so maybe the equation is incorrect?

As you asked, here is the whole program (written in Python):

@property
def autocorrelation(self):
    n = self.packet_sent
    mean = self.mean
    waiting_times = self.waiting_times
    R = [ sum([(x - mean) ** 2 for x in waiting_times[:-1]]) / n ]
    #print R

    for k in range(1, n / 4 + 1):
        R.append(0)
        for i in range(0, n - k):
            R[k] += (waiting_times[i] - mean) * (waiting_times[i + k] - mean)
        R[k] /=  n

    auto_cor = [r / R[0] for r in R]
    return auto_cor

@property
def standard_deviation_wrong(self):
    '''This must be a wrong method'''
    s_x = self.standard_deviation_simple
    auto_cor = self.autocorrelation
    s = 0
    n = self.packet_sent
    for k, r in enumerate(auto_cor[1:]):
        s += 1 - (k + 1.0) * r / n
        #print "%f %f %f" % (k, r, s)
    s *= 2
    s += 1
    s = ((s_x ** 2) * s) ** 0.5
    return s


The correlogram can be calculated with the function acf() too.

-k

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号