博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
相似度计算
阅读量:2235 次
发布时间:2019-05-09

本文共 949 字,大约阅读时间需要 3 分钟。

import numpy as npimport scipy.statsimport pandas as pdimport matplotlib.pyplot as pltimport fastdtwdef plot_pic(x, y, z):    plt.figure()    plt.plot(x, color = 'r', label = 'x')    plt.plot(y,  color = 'b',label = 'y')    plt.plot(z,  color = 'y',label = 'z')     plt.legend()    plt.show()# 随机生成两个离散型分布# x = [np.random.randint(1, 11) for i in range(10)]# y = [np.random.randint(1, 11) for i in range(10)]x = [10, 4, 9, 9, 3, 3, 3, 9, 2, 9]y = [1, 3, 9, 1, 10, 4, 9, 9, 3, 3]z = [10, 4, 5, 4, 3, 3, 2, 5, 2, 9]print(x)print(y)KL = scipy.stats.entropy(x, y) print("KL散度x-y:", KL)KL = scipy.stats.entropy(y, x) print("KL散度y-x:", KL)print('spearman---x-y: ', pd.Series(x).corr(pd.Series(y),method='spearman'))dis, _ = fastdtw(x, y)print('')print('*'*30)KL = scipy.stats.entropy(x, z) print("KL散度x-z:", KL)KL = scipy.stats.entropy(z, x) print("KL散度z-x:", KL)print('spearman---x-z: ', pd.Series(x).corr(pd.Series(z),method='spearman'))plot_pic(x, y, z)

转载地址:http://czmfb.baihongyu.com/

你可能感兴趣的文章
阿里云《云原生》公开课笔记 第一章 云原生启蒙
查看>>
阿里云《云原生》公开课笔记 第二章 容器基本概念
查看>>
阿里云《云原生》公开课笔记 第三章 kubernetes核心概念
查看>>
阿里云《云原生》公开课笔记 第四章 理解Pod和容器设计模式
查看>>
阿里云《云原生》公开课笔记 第五章 应用编排与管理
查看>>
阿里云《云原生》公开课笔记 第六章 应用编排与管理:Deployment
查看>>
阿里云《云原生》公开课笔记 第七章 应用编排与管理:Job和DaemonSet
查看>>
阿里云《云原生》公开课笔记 第八章 应用配置管理
查看>>
阿里云《云原生》公开课笔记 第九章 应用存储和持久化数据卷:核心知识
查看>>
linux系统 阿里云源
查看>>
国内外helm源记录
查看>>
牛客网题目1:最大数
查看>>
散落人间知识点记录one
查看>>
Leetcode C++ 随手刷 547.朋友圈
查看>>
手抄笔记:深入理解linux内核-1
查看>>
内存堆与栈
查看>>
Leetcode C++《每日一题》20200621 124.二叉树的最大路径和
查看>>
Leetcode C++《每日一题》20200622 面试题 16.18. 模式匹配
查看>>
Leetcode C++《每日一题》20200625 139. 单词拆分
查看>>
Leetcode C++《每日一题》20200626 338. 比特位计数
查看>>