Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
839 B
2
Indexable
Never
def my_cov(*args):
    data = np.array([*args],dtype=object)
    means = []
    n = data.shape[1]
    
    for x,y in enumerate(data):
        if x > 0:
            if len(data[x-1]) != len(data[x]):
                return None
    #Creating a means array
    for row in data:
        means.append(sum(row)/(len(row)))
    
    #Creating a sub array
    #for x,y in enumerate(data):
        #for i in y:
            #print(i)
        #i = 0
        #print(x,y,means[x])
        #print(y[i], means[x])
        #print(sum(y)-means[x])
    
    #for i in range(0,n-1):
    #for x,y in enumerate(data):
        #print(data[x], means[x])
        #if x > 0:
            #print(sum((data[x-1] - means[x-1])*(data[x] - means[x]))/(n-1)) this is just the cov, but we need the matrix
            #print((data[x-1] - means[x-1])*(data[x] - means[x]))