bubble-economy /

Full commit
"""code to simply compare the different MI solutions available to us and see
if they are approximately commensurable. Specifically this allows us to see if Slonim's method is worth the computational expense. (short answer - no)"""

import mi
import numpy as np

def main():
    """actual MI values inference"""
    v1 = np.linspace(-5000,5000, 10001)
    v2 = v1**2
    noise = np.random.uniform(-1,1,10001)
    v3 = v1 + 100*noise
    v4 = v1 + 10000*noise
    #we have enough samples to find positive MI for this one (~1.5)
    v5 = np.cos(np.linspace(-np.pi, np.pi, 10001)*10)
    #statistically validly we shoudl eb able to get a small amount of MI for this (~0.16)
    v6 = np.cos(np.linspace(-np.pi, np.pi, 10001)*30)
    #None for this guy.
    v7 = np.cos(np.linspace(-np.pi, np.pi, 10001)*60)
    tests = [
        ("v1 versus self - 5.64", v1, v1),
        ("v1 versus v2 (self squared) - 4.9", v1, v2),
        ("v1 versus v3 (self perturbed with 1% noise) - 4.6", v1, v3),
        ("v1 versus v4 (self perturbed with 100% noise) - 0.3", v1, v4),
        ("v1 versus v5 (many-branched function - gentle (H~1.5))", v1 ,v5),
        ("v1 versus v6 (many-branched function - marginal (H~0.16))", v1, v6),
        ("v1 versus v7 (many-branched function - hopeless (H~0))", v1, v7)
    for test_name, X, Y in tests:
        print "========================================"
        print test_name
        print '----------------------------------------'
        print "ince_mi_dist_cont", mi.ince_mi_dist_cont(X, Y)
        print "mi_slonim", mi.mi_slonim(X, Y)
        print "mi_dist_bloody_minded", mi.mi_dist_bloody_minded(X, Y)

if __name__ == '__main__':