Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 计算三个向量的皮尔逊相关_Python_Math_Correlation_Pearson Correlation - Fatal编程技术网

Python 计算三个向量的皮尔逊相关

Python 计算三个向量的皮尔逊相关,python,math,correlation,pearson-correlation,Python,Math,Correlation,Pearson Correlation,我想计算三个向量的皮尔逊相关性。比如: np.corrcoef(X,Y,Z) 有人知道如何在Python中实现这一点吗?有图书馆吗 非常感谢 创建二维阵列: import numpy as np X = np.random.randint(0,100,100) Y = np.random.randint(0,100,100) Z = np.random.randint(0,100,100) spam = np.array([X,Y,Z]) 然后对其运行np.corrcoff: eggs =

我想计算三个向量的皮尔逊相关性。比如:

np.corrcoef(X,Y,Z)
有人知道如何在Python中实现这一点吗?有图书馆吗

非常感谢

创建二维阵列:

import numpy as np

X = np.random.randint(0,100,100)
Y = np.random.randint(0,100,100)
Z = np.random.randint(0,100,100)
spam = np.array([X,Y,Z])
然后对其运行np.corrcoff:

eggs = np.corrcoef(spam)

spam
array([[12,  1, 23, 95, 58, 37, 38, 76, 99, 24, 50, 47, 29, 67, 38, 62,
        28, 39, 26, 32, 55, 11, 67, 71, 71, 50,  9, 54, 59, 22, 70, 63,
        11, 43, 30, 54, 14, 11, 89, 68, 98, 27, 18, 66, 14, 23, 83, 81,
        24, 90, 56, 40,  3, 94, 86, 54, 66, 68, 96, 74, 46, 19, 58, 74,
         7, 73, 93, 91, 10, 75, 32, 91, 45, 57, 81, 96, 20, 25, 18, 86,
        59, 58, 94, 97, 10, 11,  6, 30, 28, 76, 56, 86, 64, 38, 26, 25,
        26, 77, 76,  0],
       [76, 54, 66, 16, 97, 22, 66, 59, 90, 67, 85, 58, 49, 13, 36, 44,
        91, 20, 63,  2,  1, 51, 66, 12, 32, 10, 48, 88,  6, 96, 68, 60,
        22, 24, 51,  2, 94, 95, 98, 79, 24, 22, 94, 69, 36, 37, 50, 94,
         8,  2, 15, 80, 99, 77, 15, 95, 76, 25,  0, 69, 46, 21, 47, 87,
        88,  6, 34, 63, 46, 12, 62,  4, 36, 89, 21, 44, 96, 22, 11, 14,
        63, 55, 70, 58, 33, 93, 88, 39,  0, 18,  9, 92, 37, 13, 12, 67,
        98, 34,  9,  6],
       [56, 21, 61, 55, 82, 60, 13, 36, 17, 52, 93, 88, 65, 29, 67, 81,
        65, 59, 33, 89, 58, 99, 78,  1, 75, 39, 10, 75, 94, 57, 42, 32,
        19,  7, 77, 82, 96, 61, 94, 50, 61, 13, 21, 51, 70, 14, 60, 79,
        32, 29, 22, 93, 31, 19, 74, 37, 85, 74, 50, 50, 37,  5, 33, 39,
        75, 32, 43, 10, 74, 39, 74, 26, 57, 38, 79, 90, 63, 13, 53, 57,
        44,  4, 13, 39, 14, 97, 21, 81,  2, 49, 72,  5, 72, 32, 63, 37,
        53, 31,  8, 12]])
eggs
array([[ 1.        , -0.14396307, -0.01107133],
       [-0.14396307,  1.        ,  0.17098877],
       [-0.01107133,  0.17098877,  1.        ]])

要求我们推荐或查找书籍、工具、软件库、教程或其他非现场资源的问题对于堆栈溢出来说是离题的,因为它们往往会吸引自以为是的答案和垃圾邮件。相反,请描述问题以及迄今为止为解决问题所做的工作。