{"id":205451,"date":"2025-05-29T13:16:34","date_gmt":"2025-05-29T05:16:34","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205451\/"},"modified":"2025-05-29T13:16:34","modified_gmt":"2025-05-29T05:16:34","slug":"numpy-correlate%e5%87%bd%e6%95%b0%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86%e5%a4%9a%e7%bb%b4%e6%95%b0%e7%bb%84%e5%8f%8a%e5%85%b6%e6%9b%bf%e4%bb%a3%e6%96%b9%e6%b3%95%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205451\/","title":{"rendered":"NumPy correlate\u51fd\u6570\u5982\u4f55\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u53ca\u5176\u66ff\u4ee3\u65b9\u6cd5\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>NumPy correlate\u51fd\u6570\u5982\u4f55\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u53ca\u5176\u66ff\u4ee3\u65b9\u6cd5\uff1f<\/h1>\n<p>\u77e5\u8bc6\u70b9\u638c\u63e1\u4e86\uff0c\u8fd8\u9700\u8981\u4e0d\u65ad\u7ec3\u4e60\u624d\u80fd\u719f\u7ec3\u8fd0\u7528\u3002\u4e0b\u9762\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u5b9e\u6218\uff0c\u624b\u628a\u624b\u6559\u5927\u5bb6\u5b66\u4e60\u300aNumPy correlate\u51fd\u6570\u5982\u4f55\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u53ca\u5176\u66ff\u4ee3\u65b9\u6cd5\uff1f\u300b\uff0c\u5728\u5b9e\u73b0\u529f\u80fd\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5e26\u5927\u5bb6\u91cd\u65b0\u6e29\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6e29\u6545\u800c\u77e5\u65b0\uff0c\u56de\u5934\u770b\u770b\u8bf4\u4e0d\u5b9a\u53c8\u6709\u4e0d\u4e00\u6837\u7684\u611f\u609f\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241202\/1733128953674d72f912a7f.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u591a\u7ef4\u6570\u7ec4\u4e0a\u7684 numpy.correlate \u51fd\u6570<\/strong><\/p>\n<p>\u5728\u591a\u7ef4\u6570\u7ec4\u4e0a\u4f7f\u7528 numpy.correlate \u51fd\u6570\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u5b83\u53ea\u80fd\u5904\u7406\u4e00\u7ef4\u6570\u7ec4\u3002\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u6709\u591a\u7ef4\u6570\u7ec4\uff0c\u9700\u8981\u5c06\u5176\u5c55\u5e73\u6210\u4e00\u7ef4\u6570\u7ec4\u3002<\/p>\n<p>\u4f7f\u7528 ravel \u65b9\u6cd5\u5c55\u5e73\u6570\u7ec4\u662f\u6b63\u786e\u7684\u505a\u6cd5\u3002\u4f46\u662f\uff0c\u8bf7\u6ce8\u610f\uff0c\u5c55\u5e73\u540e\u8fdb\u884c\u76f8\u5173\u6027\u8ba1\u7b97\u7684\u7ed3\u679c\u662f\u5426\u6709\u610f\u4e49\u53d6\u51b3\u4e8e\u60a8\u7684\u5177\u4f53\u5e94\u7528\u573a\u666f\u3002<\/p>\n<p><strong>\u66ff\u4ee3\u65b9\u6cd5<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u5e0c\u671b\u5728\u591a\u7ef4\u6570\u7ec4\u4e0a\u8fdb\u884c\u76f8\u5173\u6027\u5206\u6790\uff0c\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u66ff\u4ee3\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\n<p><strong>\u9010\u7ef4\u76f8\u5173\u6027\uff1a<\/strong>\u5bf9\u6bcf\u4e00\u7ef4\u5ea6\u5206\u522b\u8fdb\u884c\u76f8\u5173\u6027\u8ba1\u7b97\uff0c\u7136\u540e\u6c47\u603b\u7ed3\u679c\u3002<\/p>\n<pre>import numpy as np\n\n# \u793a\u4f8b\u591a\u7ef4\u6570\u7ec4\nt = np.random.rand(3, 3)\nq = np.random.rand(3, 3)\n\n# \u5b58\u50a8\u6bcf\u4e00\u7ef4\u5ea6\u7684\u76f8\u5173\u6027\u7ed3\u679c\ncorrelations = []\nfor i in range(t.shape[0]):\n  correlations.append(np.correlate(t[i, :], q[i, :], mode='full'))\n\n# \u6c47\u603b\u7ed3\u679c\nmatch_degree = np.array(correlations)\nprint(match_degree)<\/pre>\n<\/li>\n<li><strong>\u4f7f\u7528\u591a\u7ef4\u76f8\u5173\u51fd\u6570\uff1a<\/strong>\u67d0\u4e9b\u5e93\u63d0\u4f9b\u4e86\u591a\u7ef4\u76f8\u5173\u51fd\u6570\uff0c\u4f8b\u5982 scipy \u7684 scipy.stats.contingency.crosstab \u51fd\u6570\u3002<\/li>\n<li><strong>\u5bf9\u6570\u7ec4\u8fdb\u884c\u5207\u7247\uff1a<\/strong>\u5c06\u591a\u7ef4\u6570\u7ec4\u6309\u7ef4\u5ea6\u5207\u6210\u4e00\u7cfb\u5217\u4e00\u7ef4\u6570\u7ec4\uff0c\u7136\u540e\u5bf9\u5b83\u4eec\u5206\u522b\u8fdb\u884c\u76f8\u5173\u6027\u8ba1\u7b97\u3002<\/li>\n<\/ul>\n<p>\u9009\u62e9\u6700\u9002\u5408\u60a8\u9700\u6c42\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u60a8\u5177\u4f53\u7684\u6570\u636e\u548c\u5e94\u7528\u573a\u666f\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aNumPy correlate\u51fd\u6570\u5982\u4f55\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u53ca\u5176\u66ff\u4ee3\u65b9\u6cd5\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NumPy correlate\u51fd&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-205451","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=205451"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205451\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}