spkit.entropy_diff_cond

spkit.entropy_diff_cond(X, Y, present_first=True)

Conditional Entropy \(H_{\partial}(X_{i+1}|X_i,Y_i)\)

Conditional Entropy

Information of \(X(i+1)\) given \(X(i)\) and \(Y(i)\)

\[H_{\partial}(X_{i+1}|X_i,Y_i) = H(X_{i+1},X_i,Y_i) - H(X_i,Y_i)\]
Parameters:
X: 2d-array,
  • multi-dimentional signal space, where each column (axis=1) are the delayed signals

Y: 2d-array,
  • multi-dimentional signal space, where each column (axis=1) are the delayed signals

present_first: bool, default=True
  • if True, X[:,0] is present, and X[:,1:] is past, in incresing order

  • if True, X[:,-1] is present, and X[:,:-1] is past

Returns:
H_x1y: scaler
  • Conditional Entropy

See also

entropy_diff_cond_self

Self-Conditional Entropy

Examples

#sp.entropy_diff_cond
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
X, fs, ch_names = sp.data.eeg_sample_14ch()
X = X - X.mean(1)[:, None]
X1 = sp.signal_delayed_space(X[:,0].copy(),emb_dim=5,delay=2)
Y1 = sp.signal_delayed_space(X[:,2].copy(),emb_dim=5,delay=2)
Y2 = sp.add_noise(Y1,snr_db=0)
H_xy1 = sp.entropy_diff_cond(X1,Y1,present_first=True)
H_xy2 = sp.entropy_diff_cond(X1,Y2,present_first=True)
H_y1x = sp.entropy_diff_cond(Y1,X1,present_first=True)
H_y2x = sp.entropy_diff_cond(Y2,X1,present_first=True)
print('Conditional Entropy')
print(f'- H(X1|Y1) = {H_xy1}')
print(f'- H(X1|Y2) = {H_xy2}')
print(f'- H(Y1|X1) = {H_y1x}')
print(f'- H(Y2|X1) = {H_y2x}')