matlab如何计算散度,Kullback-Leibler散度计算程序

该博客介绍了MATLAB中计算Kullback-Leibler(KL)散度和Jensen-Shannon(JS)散度的函数`kldiv`。该函数用于计算两个分布之间的距离,可以处理重复值和概率为零的情况。通过示例展示了如何使用`kldiv`进行计算,并提供了相关参考文献。
摘要由CSDN通过智能技术生成

function KL = kldiv(varValue,pVect1,pVect2,varargin)

%KLDIV Kullback-Leibler or Jensen-Shannon divergence between two distributions.

%   KLDIV(X,P1,P2) returns the Kullback-Leibler divergence between two

%   distributions specified over the M variable values in vector X.  P1 is a

%   length-M vector of probabilities representing distribution 1, and P2 is a

%   length-M vector of probabilities representing distribution 2.  Thus, the

%   probability of value X(i) is P1(i) for distribution 1 and P2(i) for

%   distribution 2.  The Kullback-Leibler divergence is given by:

%

%       KL(P1(x),P2(x)) = sum[P1(x).log(P1(x)/P2(x))]

%

%   If X contains duplicate values, there will be an warning message, and these

%   values will be treated as distinct values.  (I.e., the actual values do

%   not enter into the computation, but the probabil

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值