# Path: pyBN/utils/data.py
# def unique_bins(data):
# 	"""
# 	Get the unique values for each column in a dataset.
# 	"""
# 	bins = np.empty(len(data.T), dtype=np.int32)
# 	i = 0
# 	for col in data.T:
# 		bins[i] = len(np.unique(col))
# 		i+=1
# 	return bins


import numpy as np
from scipy import stats
from pyBN.utils.data import unique_bins
"""
******************************
Conditional Independence Tests 
for Constraint-based Learning
******************************

Implemented Constraint-based Tests
----------------------------------
- mutual information
- Pearson's X^2

I may consider putting this code into its own class structure. The
main benefit I could see from doing this would be the ability to 
cache joint/marginal/conditional probabilities for expedited tests.

"""

__author__ = """Nicholas Cullen <ncullen.th@dartmouth.edu>"""


def are_independent(data, alpha=0.05, method='mi_test'):
	pval = mi_test(data)
	if pval < alpha:
		return True
	else:
		return False

def mutual_information(data, conditional=False):
	#bins = np.amax(data, axis=0)+1 # read levels for each variable

# Path: pyBN/utils/data.py
# def unique_bins(data):
# 	"""
# 	Get the unique values for each column in a dataset.
# 	"""
# 	bins = np.empty(len(data.T), dtype=np.int32)
# 	i = 0
# 	for col in data.T:
# 		bins[i] = len(np.unique(col))
# 		i+=1
# 	return bins


# Path: pyBN/utils/independence_tests.py
import numpy as np
from scipy import stats
from pyBN.utils.data import unique_bins

"""
******************************
Conditional Independence Tests 
for Constraint-based Learning
******************************

Implemented Constraint-based Tests
----------------------------------
- mutual information
- Pearson's X^2

I may consider putting this code into its own class structure. The
main benefit I could see from doing this would be the ability to 
cache joint/marginal/conditional probabilities for expedited tests.

"""

__author__ = """Nicholas Cullen <ncullen.th@dartmouth.edu>"""


def are_independent(data, alpha=0.05, method='mi_test'):
	pval = mi_test(data)
	if pval < alpha:
		return True
	else:
		return False

def mutual_information(data, conditional=False):
	#bins = np.amax(data, axis=0)+1 # read levels for each variable

	bins = unique_bins(data)