更改

添加515字节 、 2025年12月21日 (日) 18:12
第739行: 第739行:  
不出所料,<math>X_1</math>和<math>X_2</math>传达的关于Y的唯一信息是{0:1},这是协同信息。
 
不出所料,<math>X_1</math>和<math>X_2</math>传达的关于Y的唯一信息是{0:1},这是协同信息。
   −
下面介绍如何用dit库进行一次完整的部分信息分解实验:(详见https://dit.readthedocs.io/en/latest/measures/pid.html)
+
下面介绍如何用dit库进行一次完整的部分信息分解实验:(详见https://dit.readthedocs.io/en/latest/measures/pid.html)(以Williams & Beer为例)
    +
首先在python里导入dit.pit:In [1]: from dit.pid import *
    +
随后给出一个分布:In [2]: d = dit.Distribution(['000', '011', '102', '113'], [1/4]*4)
 +
 +
 +
用给出的分布进行PID分解:In [3]: PID_WB(d)
 +
 +
输出结果:Out[13]:
 +
 +
+--------+--------+--------+
 +
 +
| I_min  |  I_r  |  pi  |
 +
 +
+--------+--------+--------+
 +
 +
| {0:1}  | 2.0000 | 1.0000 |
 +
 +
|  {0}  | 1.0000 | 0.0000 |
 +
 +
|  {1}  | 1.0000 | 0.0000 |
 +
 +
| {0}{1} | 1.0000 | 1.0000 |
 +
 +
+--------+--------+--------+
 
还有专门实现PID计算的pietromarchesi库:https://github.com/pietromarchesi/pidpy
 
还有专门实现PID计算的pietromarchesi库:https://github.com/pietromarchesi/pidpy
    
pidpy 支持任何数量的特征变量,其取值为二进制。对于取值为非二进制整数变量的情况,仅支持三元组。一般来说,一个好的经验法则是确保 n_variables < log2(n_samples / (3*n_labels))。
 
pidpy 支持任何数量的特征变量,其取值为二进制。对于取值为非二进制整数变量的情况,仅支持三元组。一般来说,一个好的经验法则是确保 n_variables < log2(n_samples / (3*n_labels))。
   −
主类 PIDCalculator 可以用形状为 (n_samples, n_variables) 的特征数组 X 和形状为 (n_samples,) 的标签数组 y 来实例化,
+
主类 PIDCalculator 可以用形状为 (n_samples, n_variables) 的源头变量数组输入 X 和形状为 (n_samples,) 的标签数组输入y,
    
python代码如下:
 
python代码如下:
175

个编辑