在Matlab中实现“概率测度的总变差距离”。

huangapple go评论57阅读模式
英文:

Implement the "Total variation distance of probability measures" in Matlab

问题

我正在尝试在Matlab中实现概率测度的总变差距离(TVD)。

使用max函数来计算TVD方程式(下面)的"最大值"是否正确?

我的尝试:

% 输入
A = [0.444643925792938 0.258402203856749
     0.224416517055655 0.309641873278237
     0.0730101735487732 0.148209366391185
     0.0825852782764812 0.0848484848484849
     0.0867743865948534 0.0727272727272727
     0.0550568521843208 0.0440771349862259
     0.00718132854578097 0.0121212121212121
     0.00418910831837223 0.0336088154269972
     0.00478755236385398 0.0269972451790634
     0.00359066427289048 0.00110192837465565
     0.00538599640933573 0.00220385674931129
     0.000598444045481747 0
     0.00299222022740874 0.00165289256198347
     0 0
     0.00119688809096349 0.000550964187327824
     0 0.000550964187327824
     0.00119688809096349 0.000550964187327824
     0 0.000550964187327824
     0 0.000550964187327824
     0.000598444045481747 0
     0.000598444045481747 0
     0 0
     0 0.000550964187327824
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0.000598444045481747 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0 0
     0.00119688809096349 0.000550964187327824];
P = A(:,1);
Q = A(:,2);

% 总变差距离(概率测度)
d = max(abs(P-Q))

这导致:

d = 0.186241721936189
英文:

I am trying to implement the Total variation distance of probability measures (TVD) in Matlab.
Would it be correct to use the max function, in order to calculate the "supremum" of the TVD equation (here below)?

在Matlab中实现“概率测度的总变差距离”。

My attempt:

% Input
A =[     0.444643925792938         0.258402203856749
         0.224416517055655         0.309641873278237
        0.0730101735487732         0.148209366391185
        0.0825852782764812        0.0848484848484849
        0.0867743865948534        0.0727272727272727
        0.0550568521843208        0.0440771349862259
       0.00718132854578097        0.0121212121212121
       0.00418910831837223        0.0336088154269972
       0.00478755236385398        0.0269972451790634
       0.00359066427289048       0.00110192837465565
       0.00538599640933573       0.00220385674931129
      0.000598444045481747                         0
       0.00299222022740874       0.00165289256198347
                         0                         0
       0.00119688809096349      0.000550964187327824
                         0      0.000550964187327824
       0.00119688809096349      0.000550964187327824
                         0      0.000550964187327824
                         0      0.000550964187327824
      0.000598444045481747                         0
      0.000598444045481747                         0
                         0                         0
                         0      0.000550964187327824
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0      0.000550964187327824
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
                         0                         0
       0.00119688809096349      0.000550964187327824];
P   = A(:,1);
Q   = A(:,2);

% Total variation distance (of probability measures)
d = max(abs(P-Q))

Which leads to:

d = 0.186241721936189

答案1

得分: 3

如果你的概率测度以有限集合为支撑(这在数值逼近中是必然的情况),那么是的,存在一个最大值,并与最大上界相符。

如果你的有限数据只是对实际的基础分布的近似,可能定义在一个无限集合上,那么你的数据的最大值只会是对真实分布的实际最大上界的近似。不管怎样,在这种情况下,使用数据的最大值也可能是有意义的。

英文:

If your probability measures have a finite set as support (as is necessarily the case with numerical approximations) then yes, a maximum exists and coincides with the supremum.

If your finite data is only an approximation to the actual, underlying distributions, possibly defined on an infinite set, then the maximum of your data will only be an approximation of the actual supremum for the true distributions. Anyway, in that case it would also probably make sense to use the maximum of the data.

答案2

得分: 0

正确的Matlab代码来自一个名叫"Bruno Luong"的Matlab用户:

dFormula = 0.5 * norm(P-Q,1)

对应于:

在Matlab中实现“概率测度的总变差距离”。

来源于:
https://ch.mathworks.com/matlabcentral/answers/1991183-implement-the-total-variation-distance-tvd-in-matlab?s_tid=mlc_ans_email_ques

英文:

The correct Matlab's code would come from a Matlab's user called "Bruno Luong":

dFormula = 0.5 * norm(P-Q,1)

corresponding to:

在Matlab中实现“概率测度的总变差距离”。
from:
https://ch.mathworks.com/matlabcentral/answers/1991183-implement-the-total-variation-distance-tvd-in-matlab?s_tid=mlc_ans_email_ques

huangapple
  • 本文由 发表于 2023年7月3日 21:40:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76605304.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定