###两个变量之间的皮尔逊相关系数定义为两个变量之间的协方差和标准差的商:
上式定义了总体相关系数,常用希腊小写字母p 作为代表符号。估算样本的协方差和标准差,可得到皮尔逊相关系数,常用英文小写字母 r 代表:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 29 14:17:12 2018
@author: Dawn
"""
import numpy as np
from scipy.spatial.distance import pdist
import face_recognition
import cv2
#计算皮尔逊相关度:
def pearson(p,q):
#只计算两者共同有的
# same = 0
# for i in p:
# if i in q:
# same +=1
#
# n = same
#分别求p,q的和
n = len(p)
sumx = sum([p[i] for i in range(n)])
sumy = sum([q[i] for i in range(n)])
#分别求出p,q的平方和
sumxsq = sum([p[i]**2 for i in range(n)])
sumysq = sum([q[i