Skip to content

Commit 62153c2

Browse files
committed
.
1 parent 244a7a8 commit 62153c2

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

causalspyne/utils_cov_precision.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import numpy as np
2+
3+
def estimate_spectrum_radius(arr_df):
4+
mat_corr = np.corrcoef(arr_df.T)
5+
mat_cov = np.cov(arr_df.T)
6+
mat_precision = np.linalg.inv(mat_cov)
7+
arr_eig_values, eigvec = np.linalg.eig(mat_precision)
8+
return np.max(arr_eig_values)

examples/example.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from causalspyne import gen_partially_observed
2+
from causalspyne.utils_cov_precision import estimate_spectrum_radius
23

34

4-
gen_partially_observed(size_micro_node_dag=3,
5-
num_macro_nodes=3,
6-
degree=2, # average vertex/node degree
7-
list_confounder2hide=[0.1, 1.0], # choie of confounder to hide: percentile or index of all toplogically sorted confounders
8-
num_sample=200,
9-
graphviz=True)
5+
subview = gen_partially_observed(size_micro_node_dag=3,
6+
num_macro_nodes=3,
7+
degree=2,
8+
list_confounder2hide=[0],
9+
num_sample=200,
10+
graphviz=True)
11+
12+
radius = estimate_spectrum_radius(subview.data)
13+
print(radius)

0 commit comments

Comments
 (0)