Problem 5.1


In [9]:
%matplotlib inline
import pylab
from __future__ import division
pylab.rcParams['figure.figsize'] = (16, 10)
import scipy.io as sio
import numpy as np
import math
import matplotlib.pyplot as plt
data = sio.loadmat('../data/programming/hw1progde.mat')
test_data = data['x_te']
training_data = data['x_tr']
h = 0.01

## 10 different measures, whcih one isbest? training or validation

In [10]:
def K(x, XI, h, kernel_type='gaussian'):
    """
    Parameters
    ----------
    x: Point location
    XI: Vector of training data
    """
    if kernel_type == 'gaussian':
        s=0
        l=0
        for xi in XI:
            u = (x-xi)/h
            l+=1
            e = (1/math.sqrt(2*math.pi))*math.exp(-u*u/2)
            s+=e
        return s/(l*h)
    elif kernel_type == 'epanechnikov':
        s=0
        l=0
        for xi in XI:
            u = (x-xi)/h
            l+=1
            if abs(u)<=1:
                s+=(3/4)*(1-u*u)
        return s/(l*h)
    elif kernel_type == 'histogram':
        s=0
        l=0
        for xi in XI:
            u = (x-xi)/h
            l+=1
            if abs(u)<=1:
                s+=0.5
        return s/(l*h)

def inrange(x,Y):
    if x<Y[1] and X>=Y[0]:
        return True 
    return False

def histogram(x, bandwidth=1):
    min_x = np.min(x)
    max_x = np.max(x)
    range_x = max_x-min_x
    bins = math.ceil(range_x/bandwidth)
    list_of_bins = []
    for i in range(bins):
        list_of_bins.append([min_x+bandwidth*i, min_x+bandwidth*(i+1)])
    counts = np.zeros(bins)
    for xi in x:
        for lindex, lb in enumerate(list_of_bins):
            if inrange(xi, lb):
                counts[lindex]+=1
    return counts

Gaussian

$$ K(u) = \frac{1}{\sqrt{2\pi}} e^{-\frac{u^2}{2}} \forall u \in \mathbb{R} $$$$ h = (\frac{4\sigma^5}{3n})^{\frac{1}{5}} \approx 0.94\sigma n^{-\frac{1}{5}} $$

In [11]:
## Optimum bandwidth calculation
sigma_tr = np.std(training_data)
sigma_te = np.std(test_data)

h = 0.94*sigma_tr*len(training_data)**(-0.2)

print(sigma_tr)
print(sigma_te)
print(h)


0.262856444965
0.258378205441
0.0712939180627

In [12]:
H = [0.01,0.07,0.05,0.1,0.5, 0.7]
output_gaussian = []
x_points = np.linspace(0.1,1)

for h in H:
    gaussian_r = [K(x,training_data, h, 'gaussian') for x in x_points]
    output_gaussian.append(gaussian_r)

In [13]:
f, axarr = plt.subplots(2, 3)
for i, gaussian_r in enumerate(output_gaussian):
    if i<3:
        axarr[0, i].plot(np.sort(x_points), gaussian_r)
        axarr[0, i].set_title('Gaussian, h={}'.format(H[i]))
    else:
        axarr[1, i-3].plot(np.sort(x_points), gaussian_r)
        axarr[1, i-3].set_title('Gaussian, h={}'.format(H[i]))
f.show()


/home/saket/anaconda/lib/python2.7/site-packages/matplotlib/figure.py:387: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure
  "matplotlib is currently using a non-GUI backend, "

Epanechnikov kernel

$$ K(u) = \begin{cases} \frac{3}{4}[1-u^2] & |u| \in [0,1],\\ 0 & otherwise \end{cases} $$

In [14]:
ev_r = []
for h in H:
    r = [K(x,training_data, h, 'epanechnikov') for x in x_points]
    ev_r.append(r)

In [15]:
f, axarr = plt.subplots(2, 3)
for i, gaussian_r in enumerate(ev_r):
    if i<3:
        axarr[0, i].plot(np.sort(x_points), gaussian_r)
        axarr[0, i].set_title('Ev, h={}'.format(H[i]))
    else:
        axarr[1, i-3].plot(np.sort(x_points), gaussian_r)
        axarr[1, i-3].set_title('Ev, h={}'.format(H[i]))
f.show()


Histogram

$$ K(u) = \begin{cases} \frac{1}{2} & |u| \leq 1\\ 0 & otherwise \\ \end{cases} $$

In [16]:
hi_r = []
for h in H:
    r = [K(x,training_data, h, 'histogram') for x in x_points]
    hi_r.append(r)

In [17]:
f, axarr = plt.subplots(2, 3)
for i, gaussian_r in enumerate(hi_r):
    if i<3:
        axarr[0, i].plot(np.sort(x_points), gaussian_r)
        axarr[0, i].set_title('hist, h={}'.format(H[i]))
    else:
        axarr[1, i-3].plot(np.sort(x_points), gaussian_r)
        axarr[1, i-3].set_title('hist, h={}'.format(H[i]))
f.show()



In [18]:
## Randomly partion test_Data into 19 subsets
import random
N_split = 19
test_data_shuffled = test_data.copy()
random.shuffle(test_data_shuffled)
list_size = int(len(test_data_shuffled)/N_split)
list_of_shuffled_te = [test_data_shuffled[0+list_size*i : list_size*(i+1)] for i in xrange(N_split)]

x_points = np.linspace(0.1,1)
def calc_variance(x_points, list_of_shuffled_te,h,kernel):
    f_scores=[]
    for index, lte in enumerate(list_of_shuffled_te):
        f_scores.append([])
        for x in x_points:
            de = K(x, lte, h, kernel);all
            f_scores[index].append(de)

    f_hn = np.array([np.sum(a) for a in f_scores])
    f_h = np.mean(f_hn)
    q = np.sum((f_hn-f_h)**2)
    E=q/N_split
    return E
kernel = 'gaussian'
g_h = []
e_h = []
h_h = []
for h in H:
    g_h.append(calc_variance(x_points, list_of_shuffled_te,h,kernel))
print g_h
kernel = 'epanechnikov'
for h in H:
    e_h.append(calc_variance(x_points, list_of_shuffled_te,h,kernel))
    
kernel = 'histogram'
for h in H:
    h_h.append(calc_variance(x_points, list_of_shuffled_te,h,kernel))


[0.42346736334284474, 0.32351981399621649, 0.31647788696847778, 0.3674306202766176, 0.052126297026585458, 0.011691890826994403]

In [19]:
plt.plot(H,g_h)


Out[19]:
[<matplotlib.lines.Line2D at 0x7eff0b029ad0>]

In [20]:
plt.plot(H,e_h)


Out[20]:
[<matplotlib.lines.Line2D at 0x7eff0af6fe50>]

In [21]:
plt.plot(H,h_h)


Out[21]:
[<matplotlib.lines.Line2D at 0x7eff095ce790>]

Problem 2


In [1]:
import numpy as np
import math
m = [(10,49),(-12,38),(-9,47)]
ee = [(29,19),(32,31),(37,38)]
cs = [(8,9),(30,-28),(-18,-19),(-21,12)]
t = m+ee+cs
x = np.array([i[0] for i in t])
y = np.array([i[1] for i in t])

xm = np.mean(x)
ym = np.mean(y)
xsd = np.std(x, ddof=1)
ysd = np.std(y, ddof=1)
def normalise(d):
    return (round((d[0]-xm)/xsd,4), round((d[1]-ym)/ysd,4))
data = (9,18)
data_normal = normalise(data)

normalised_t = [normalise(d) for d in t]
for i in normalised_t:
    print '{} & {}'.format(i[0], i[1])
print xm, xsd
print ym, ysd

def distance_calculator(data):
    for d in normalised_t:
        l1 = round(abs(d[0]-data[0])+abs(d[1]-data[1]),4)
        l2 = round(math.sqrt(abs(d[0]-data[0])**2+abs(d[1]-data[1])**2),4)
        print ' & {} & {}'.format(l1,l2)
distance_calculator(data_normal)


0.0623 & 1.107
-0.9163 & 0.6928
-0.7829 & 1.0317
0.9074 & -0.0226
1.0409 & 0.4292
1.2633 & 0.6928
-0.0267 & -0.3991
0.9519 & -1.7922
-1.1832 & -1.4534
-1.3167 & -0.2862
8.6 22.4806089281
19.6 26.5589491091
 & 1.2117 & 1.168
 & 1.6871 & 1.1998
 & 1.8926 & 1.354
 & 0.9272 & 0.8904
 & 1.5125 & 1.1341
 & 1.9985 & 1.4554
 & 0.3834 & 0.3418
 & 2.6661 & 1.9678
 & 2.5942 & 1.8394
 & 1.5605 & 1.3535

In [2]:
m+ee+cs


Out[2]:
[(10, 49),
 (-12, 38),
 (-9, 47),
 (29, 19),
 (32, 31),
 (37, 38),
 (8, 9),
 (30, -28),
 (-18, -19),
 (-21, 12)]

In [3]:
print data_normal


(0.0178, -0.0602)

Problem 3


In [4]:
p_rain = (9+5+6+3+7+2+3+1)/80.0
p_norain = 1-p_rain

p_temp_hot = 4/8.0
p_temp_cold = 1-p_temp_hot

p_humidity_high = 4/8.0
p_humidity_low = 1-p_humidity_high

p_sky_clear = 4/8.0
p_sky_cloudy = 1-p_sky_clear




HY = -(p_rain*math.log(p_rain,2)+p_norain*math.log(p_norain,2))
print(HY)
##temperature
p_rain_hot = (9+5+6+3)/40.0
p_norain_hot = 1-p_rain_hot

p_rain_cold = (7+2+3+1)/40.0
p_norain_cold = 1-p_rain_cold

h_y_temp = p_temp_hot * -(p_rain_hot*math.log(p_rain_hot,2)+p_norain_hot*math.log(p_norain_hot,2)) + p_temp_cold *-(p_rain_cold*math.log(p_rain_cold,2)+p_norain_cold*math.log(p_norain_cold,2))
g_temp = HY-h_y_temp
##humiditiy

p_rain_high = (9+5+7+2)/40.0
p_norain_high = 1-p_rain_high

p_rain_low = (6+3+3+1)/40.0
p_norain_low = 1-p_rain_low

h_y_humidity = p_humidity_high * -(p_rain_high*math.log(p_rain_high,2)+p_norain_high*math.log(p_norain_high,2))\
                + p_humidity_low *-(p_rain_low*math.log(p_rain_low,2)+p_norain_low*math.log(p_norain_low,2))
g_humidity = HY-h_y_humidity
    
##sky

p_rain_cloudy = (9+6+7+3)/40.0
p_norain_cloudy = 1-p_rain_cloudy

p_rain_clear = (5+3+2+1)/40.0
p_norain_clear = 1-p_rain_clear


h_y_sky = p_sky_cloudy * -(p_rain_cloudy*math.log(p_rain_cloudy,2)+p_norain_cloudy*math.log(p_norain_cloudy,2))\
                + p_sky_clear *-(p_rain_clear*math.log(p_rain_clear,2)+p_norain_clear*math.log(p_norain_clear,2))

g_sky = HY-h_y_sky


0.992774453988

In [6]:
print(h_y_temp)
print(h_y_sky)


0.946722192577
0.90149109061

In [26]:
print 'Gain for Temperature: {}\tHumidity:{}\tSky:{}'.format(g_temp, g_humidity, g_sky)


Gain for Temperature: 0.0460522614106	Humidity:0.0460522614106	Sky:0.091283363378

So the root is on Sky!


In [27]:
#H[Y|Temperature,Cloudy]
p_rain_cloudy_hot = (9+6)/20.0
p_norain_cloudy_hot = 1-p_rain_cloudy_hot

p_rain_cloudy_cold = (7+3)/20.0
p_norain_cloudy_cold = 1-p_rain_cloudy_cold

p_cloudy_hot = 2/4.0
p_cloudy_cold = 2/4.0


h_cloudy_temp = p_cloudy_hot * -(p_rain_cloudy_hot*math.log(p_rain_cloudy_hot,2)+p_norain_cloudy_hot*math.log(p_norain_cloudy_hot,2))\
                +p_cloudy_cold * -(p_rain_cloudy_cold*math.log(p_rain_cloudy_cold,2)+p_norain_cloudy_cold*math.log(p_norain_cloudy_cold,2))
g_cloudy_temp = HY-h_cloudy_temp

In [28]:
#H[Y|Temperature,Cloudy]
p_rain_cloudy_high = (9+7)/20.0
p_norain_cloudy_high = 1-p_rain_cloudy_high

p_rain_cloudy_low = (6+3)/20.0
p_norain_cloudy_low = 1-p_rain_cloudy_low

p_cloudy_high = 2/4.0
p_cloudy_low = 1-p_cloudy_high


h_cloudy_hum = p_cloudy_high * -(p_rain_cloudy_high*math.log(p_rain_cloudy_high,2)+p_norain_cloudy_high*math.log(p_norain_cloudy_high,2))\
                +p_cloudy_low * -(p_rain_cloudy_low*math.log(p_rain_cloudy_low,2)+p_norain_cloudy_low*math.log(p_norain_cloudy_low,2))\

g_cloudy_hum = HY-h_cloudy_hum

In [29]:
print 'For Cloudhy Sky: Temperature: {}\t HUmidity:{}'.format(g_cloudy_temp, g_cloudy_hum)


For Cloudhy Sky: Temperature: 0.0871353917582	 HUmidity:0.13542317955

For cloudy sky, we choose humdity as the next node

For clear sky, we choose temperature


In [30]:
##For clear sky, temperature =hot
p_rain_clear_hot = (5+3)/20.0
p_norain_clear_hot = 1-p_rain_clear_hot

p_rain_clear_cold = (2+1)/20.0
p_norain_clear_cold = 1-p_rain_clear_cold

# So for Clear, hot => It rains

#p_rain_clear_cold 
#h_clear_cold = p_rain_clear_cold*()

In [31]:
%pylab inline
from __future__ import division
pylab.rcParams['figure.figsize'] = (16, 10)
import scipy.io as sio
import numpy as np
import math
import matplotlib.pyplot as plt
data = sio.loadmat('../data/programming/hw1boundary.mat')
print(data)


Populating the interactive namespace from numpy and matplotlib
{'labels': array([[ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1],
       [-1],
       [-1],
       [ 1],
       [ 1],
       [ 1],
       [-1]], dtype=int16), '__version__': '1.0', 'features': array([[ 0.88060566,  0.9069621 ],
       [ 0.61908086,  0.37887659],
       [ 0.89394076,  0.52962221],
       [ 0.2090533 ,  0.988615  ],
       [ 0.25829775,  0.95820931],
       [ 0.00412488,  0.81764608],
       [ 0.09045269,  0.42389547],
       [ 0.59582002,  0.81797653],
       [ 0.29931273,  0.44449589],
       [ 0.7754338 ,  0.38026035],
       [ 0.64238993,  0.70723517],
       [ 0.17954654,  0.23891612],
       [ 0.28334014,  0.17576511],
       [ 0.13585484,  0.23814677],
       [ 0.56349551,  0.28359162],
       [ 0.14425621,  0.04064871],
       [ 0.85605342,  0.55141668],
       [ 0.03040843,  0.94249898],
       [ 0.85032386,  0.78783661],
       [ 0.23280049,  0.24143222],
       [ 0.75493647,  0.69597555],
       [ 0.05639043,  0.01525751],
       [ 0.7076464 ,  0.76854751],
       [ 0.18412115,  0.33189269],
       [ 0.99460256,  0.32233009],
       [ 0.5166997 ,  0.7654373 ],
       [ 0.53815101,  0.38416497],
       [ 0.271514  ,  0.21862672],
       [ 0.37825698,  0.56332208],
       [ 0.51214657,  0.22063333],
       [ 0.51541855,  0.16263705],
       [ 0.46893368,  0.39964005],
       [ 0.15416716,  0.02039494],
       [ 0.21512608,  0.42327013],
       [ 0.64517282,  0.0032733 ],
       [ 0.60613917,  0.04486003],
       [ 0.18234512,  0.18912412],
       [ 0.86769146,  0.20133633],
       [ 0.5277181 ,  0.60034962],
       [ 0.97453763,  0.23172246],
       [ 0.28548482,  0.56654788],
       [ 0.949081  ,  0.55074967],
       [ 0.60760531,  0.33800629],
       [ 0.77648781,  0.98992351],
       [ 0.06348196,  0.14835925],
       [ 0.59115702,  0.85128767],
       [ 0.89975753,  0.78718001],
       [ 0.50978799,  0.52430098],
       [ 0.53283479,  0.01883896],
       [ 0.79857564,  0.26345172],
       [ 0.65509598,  0.99858972],
       [ 0.46305783,  0.71054062],
       [ 0.55731705,  0.21809033],
       [ 0.74303364,  0.64161269],
       [ 0.51432168,  0.12106825],
       [ 0.12078236,  0.55668134],
       [ 0.26808667,  0.78796821],
       [ 0.92485901,  0.41450193],
       [ 0.58939731,  0.08366441],
       [ 0.53922342,  0.58710672],
       [ 0.93726526,  0.63926646],
       [ 0.25562896,  0.12515473],
       [ 0.91190009,  0.86526168],
       [ 0.55711614,  0.48778429],
       [ 0.73868489,  0.27601782],
       [ 0.68432084,  0.31147164],
       [ 0.1397059 ,  0.66656671],
       [ 0.97348858,  0.50009808],
       [ 0.42453977,  0.44413852],
       [ 0.07621165,  0.32558251],
       [ 0.10792619,  0.56592369],
       [ 0.97224132,  0.01522272],
       [ 0.57035334,  0.55283355],
       [ 0.48382488,  0.93582422],
       [ 0.64498975,  0.4817723 ],
       [ 0.21820438,  0.32847565],
       [ 0.69490292,  0.80308169],
       [ 0.24575686,  0.14346557],
       [ 0.63361906,  0.07862275],
       [ 0.96013714,  0.44540793],
       [ 0.72642199,  0.46551034],
       [ 0.9696583 ,  0.73667864],
       [ 0.7621409 ,  0.6990372 ],
       [ 0.52509584,  0.53309033],
       [ 0.44679024,  0.20632318],
       [ 0.63836197,  0.15696725],
       [ 0.30713779,  0.40223952],
       [ 0.44340593,  0.43757587],
       [ 0.66526995,  0.97506347],
       [ 0.82227717,  0.92674419],
       [ 0.31902131,  0.30806415],
       [ 0.65704504,  0.8625826 ],
       [ 0.50540341,  0.56022728],
       [ 0.15744603,  0.54416228],
       [ 0.30507655,  0.8422796 ],
       [ 0.10510129,  0.78797087],
       [ 0.87062182,  0.53637121],
       [ 0.67895067,  0.00183038],
       [ 0.82687522,  0.37015247],
       [ 0.94606932,  0.4361208 ],
       [ 0.63060391,  0.6332025 ],
       [ 0.51340222,  0.1467774 ],
       [ 0.55599497,  0.56536703],
       [ 0.98743097,  0.40311686],
       [ 0.62690151,  0.05398181],
       [ 0.85201697,  0.13598472],
       [ 0.49025062,  0.39050965],
       [ 0.01995876,  0.45755556],
       [ 0.2438314 ,  0.33191106],
       [ 0.55007506,  0.85733266],
       [ 0.10156702,  0.60715582],
       [ 0.47431208,  0.19711833],
       [ 0.17453117,  0.14352109],
       [ 0.32538313,  0.76737995],
       [ 0.11038631,  0.65272311],
       [ 0.42823651,  0.34227988],
       [ 0.7189906 ,  0.05661104],
       [ 0.76761659,  0.4203616 ],
       [ 0.9271852 ,  0.4608638 ],
       [ 0.75695405,  0.53550264],
       [ 0.33249821,  0.82842281],
       [ 0.88055951,  0.99837009],
       [ 0.52560974,  0.38240546],
       [ 0.26734029,  0.19007998],
       [ 0.16821682,  0.99239133],
       [ 0.04501119,  0.6799368 ],
       [ 0.17077493,  0.93489602],
       [ 0.92577541,  0.63641018],
       [ 0.10862359,  0.64870462],
       [ 0.83414934,  0.38261172],
       [ 0.15181501,  0.02787361],
       [ 0.85587612,  0.59306638],
       [ 0.59856753,  0.73130523],
       [ 0.19776826,  0.65312429],
       [ 0.79753052,  0.0619616 ],
       [ 0.78738565,  0.15304079],
       [ 0.09558508,  0.75565379],
       [ 0.17144778,  0.49583322],
       [ 0.6028121 ,  0.38436908],
       [ 0.32509848,  0.28831782],
       [ 0.26728487,  0.18636646],
       [ 0.78929975,  0.94733758],
       [ 0.61661344,  0.39805639],
       [ 0.68646421,  0.13915168],
       [ 0.6974333 ,  0.54137266],
       [ 0.93202059,  0.0305164 ],
       [ 0.12018809,  0.54845004],
       [ 0.60688622,  0.39658862],
       [ 0.48986765,  0.76094562],
       [ 0.52970138,  0.16278458],
       [ 0.22186913,  0.46810012],
       [ 0.7481809 ,  0.59364466],
       [ 0.2581539 ,  0.08533438],
       [ 0.19911398,  0.49714076],
       [ 0.87152337,  0.77689876],
       [ 0.0271855 ,  0.13381792],
       [ 0.03634021,  0.70019494],
       [ 0.43799367,  0.83073111],
       [ 0.06568763,  0.51314783],
       [ 0.97938642,  0.00481381],
       [ 0.62890006,  0.35671192],
       [ 0.65632808,  0.97302173],
       [ 0.32790605,  0.14465763],
       [ 0.47549986,  0.77476574],
       [ 0.01624182,  0.3609793 ],
       [ 0.20002815,  0.28157815],
       [ 0.85849473,  0.5434095 ],
       [ 0.0675401 ,  0.40723859],
       [ 0.31074856,  0.92030386],
       [ 0.82662273,  0.35689931],
       [ 0.61186841,  0.11250923],
       [ 0.91460037,  0.2550839 ],
       [ 0.88411044,  0.15567712],
       [ 0.24531303,  0.81311088],
       [ 0.95820191,  0.62963883],
       [ 0.4522967 ,  0.65937431],
       [ 0.88855814,  0.6641176 ],
       [ 0.46485039,  0.54727703],
       [ 0.58522136,  0.28594904],
       [ 0.01167901,  0.09731316],
       [ 0.72843539,  0.83121842],
       [ 0.41530035,  0.31502044],
       [ 0.11863749,  0.59878357],
       [ 0.59625642,  0.4687677 ],
       [ 0.00468786,  0.65821134],
       [ 0.93945478,  0.2609999 ],
       [ 0.69141204,  0.28453044],
       [ 0.27179808,  0.69105664],
       [ 0.75373733,  0.97347859],
       [ 0.65833192,  0.28255815],
       [ 0.28371013,  0.85399301],
       [ 0.53561451,  0.90132798],
       [ 0.06021607,  0.83775416],
       [ 0.67742727,  0.75227974],
       [ 0.9228831 ,  0.25913128],
       [ 0.46663868,  0.94713849],
       [ 0.36881017,  0.84713232],
       [ 0.91739393,  0.8423747 ],
       [ 0.01157304,  0.77715634],
       [ 0.9292352 ,  0.47375533],
       [ 0.69341754,  0.85116553],
       [ 0.82123702,  0.92918442],
       [ 0.85773689,  0.02424365],
       [ 0.11057689,  0.72908731],
       [ 0.7049994 ,  0.46631973],
       [ 0.55166643,  0.59119377],
       [ 0.52062779,  0.98449771],
       [ 0.31373175,  0.84700749],
       [ 0.16141492,  0.97669722],
       [ 0.31972778,  0.34485521],
       [ 0.6710666 ,  0.27736325],
       [ 0.5239508 ,  0.31640724],
       [ 0.60780046,  0.33648883],
       [ 0.76031494,  0.54809991],
       [ 0.16386253,  0.28520574],
       [ 0.49436169,  0.91585924],
       [ 0.76468803,  0.6706833 ],
       [ 0.30081148,  0.78549118],
       [ 0.83886561,  0.18300538],
       [ 0.67980762,  0.14088585],
       [ 0.32846118,  0.05574465],
       [ 0.53826367,  0.61837349],
       [ 0.83781693,  0.58994139],
       [ 0.24297688,  0.37503604],
       [ 0.01948406,  0.02261822],
       [ 0.60747865,  0.15925118],
       [ 0.53879304,  0.50677288],
       [ 0.22634948,  0.78717206],
       [ 0.91994101,  0.76203759],
       [ 0.93599522,  0.93432478],
       [ 0.48862953,  0.79517996],
       [ 0.69762784,  0.45426139],
       [ 0.51658565,  0.34439868],
       [ 0.28523355,  0.1328598 ],
       [ 0.00945048,  0.56123375],
       [ 0.29294972,  0.20761525],
       [ 0.66648451,  0.11800666],
       [ 0.15509237,  0.76765466],
       [ 0.22557761,  0.45725528],
       [ 0.87762203,  0.7258431 ],
       [ 0.60572756,  0.10672557],
       [ 0.64681381,  0.43914117],
       [ 0.06918288,  0.55738801],
       [ 0.21854565,  0.85558368],
       [ 0.77999428,  0.91192935],
       [ 0.62907744,  0.3513303 ],
       [ 0.07061642,  0.37236244],
       [ 0.65721858,  0.10223546],
       [ 0.51965944,  0.65759319],
       [ 0.94752964,  0.21880986],
       [ 0.02085067,  0.86643132],
       [ 0.72871784,  0.39340489],
       [ 0.39851786,  0.45388499],
       [ 0.6872463 ,  0.18175376],
       [ 0.07308707,  0.06743853],
       [ 0.75804556,  0.78455338],
       [ 0.05072259,  0.80186698],
       [ 0.64241008,  0.46341895],
       [ 0.50077491,  0.85242263],
       [ 0.53008977,  0.62564799],
       [ 0.73825153,  0.180491  ],
       [ 0.27456845,  0.03007021],
       [ 0.23803565,  0.12977849],
       [ 0.75994311,  0.3156061 ],
       [ 0.96009444,  0.73153458],
       [ 0.16620636,  0.77298032],
       [ 0.37859389,  0.14856877],
       [ 0.09680238,  0.79579958],
       [ 0.93456239,  0.16534528],
       [ 0.80291587,  0.71710292],
       [ 0.73020533,  0.07855683],
       [ 0.79471341,  0.39386598],
       [ 0.57356962,  0.81582994],
       [ 0.36169015,  0.52997527],
       [ 0.16133366,  0.94735645],
       [ 0.88637059,  0.31668077],
       [ 0.90199869,  0.57816541],
       [ 0.75858214,  0.1902291 ],
       [ 0.36179213,  0.39226111],
       [ 0.49622488,  0.99875628],
       [ 0.65868549,  0.34368823],
       [ 0.28896678,  0.90857082],
       [ 0.14305715,  0.69766634],
       [ 0.30813312,  0.02977024],
       [ 0.3474413 ,  0.48127712],
       [ 0.13953846,  0.67690543],
       [ 0.21623853,  0.40248297],
       [ 0.55582169,  0.15409103],
       [ 0.05118374,  0.56116788],
       [ 0.41735263,  0.9493255 ],
       [ 0.71158016,  0.95929542],
       [ 0.87927304,  0.9899408 ],
       [ 0.60147944,  0.83601384],
       [ 0.46497205,  0.65408004],
       [ 0.81542064,  0.86917294],
       [ 0.32212491,  0.8637714 ],
       [ 0.37638944,  0.76192463],
       [ 0.13801572,  0.16526765],
       [ 0.65359239,  0.07947416],
       [ 0.02549197,  0.50889458],
       [ 0.23368635,  0.09304026],
       [ 0.97878212,  0.43785913],
       [ 0.94302144,  0.31197148],
       [ 0.98106385,  0.37915088],
       [ 0.06696397,  0.99559237],
       [ 0.19525747,  0.86949223],
       [ 0.42340596,  0.94790656],
       [ 0.53707643,  0.25430484],
       [ 0.46327715,  0.04849163],
       [ 0.6259094 ,  0.8318387 ],
       [ 0.5025594 ,  0.68872558],
       [ 0.79177705,  0.59602189],
       [ 0.71035192,  0.21473979],
       [ 0.56940488,  0.53516928],
       [ 0.15709878,  0.05575556],
       [ 0.62560336,  0.43104931],
       [ 0.92583332,  0.19073823],
       [ 0.98319713,  0.32777546],
       [ 0.72317358,  0.93765708],
       [ 0.18755843,  0.84736701],
       [ 0.86013173,  0.25698364],
       [ 0.1290599 ,  0.37720553],
       [ 0.74347161,  0.73351433],
       [ 0.04787844,  0.78222414],
       [ 0.64969944,  0.01163706],
       [ 0.05953712,  0.22170615],
       [ 0.91976245,  0.0670718 ],
       [ 0.17172453,  0.70565414],
       [ 0.08804642,  0.87593417],
       [ 0.3045428 ,  0.27748226],
       [ 0.67159515,  0.69280412],
       [ 0.2044433 ,  0.13901353],
       [ 0.97480967,  0.37476901],
       [ 0.03955967,  0.83587783],
       [ 0.49179107,  0.69574833],
       [ 0.64093296,  0.69489941],
       [ 0.40501614,  0.85336179],
       [ 0.05708196,  0.29458822],
       [ 0.63033699,  0.65096799],
       [ 0.21458123,  0.29862787],
       [ 0.62970941,  0.94467749],
       [ 0.39456094,  0.78078901],
       [ 0.7961077 ,  0.82501817],
       [ 0.87903694,  0.73618478],
       [ 0.78007712,  0.79367256],
       [ 0.7024826 ,  0.40515752],
       [ 0.42067223,  0.1306119 ],
       [ 0.64385583,  0.1595564 ],
       [ 0.07830899,  0.8166439 ],
       [ 0.38074997,  0.03055413],
       [ 0.43768922,  0.54399146],
       [ 0.40695144,  0.82349714],
       [ 0.27378619,  0.94839703],
       [ 0.23135103,  0.4602685 ],
       [ 0.73789795,  0.0695003 ],
       [ 0.87940004,  0.52239952],
       [ 0.77248802,  0.19585724],
       [ 0.03583289,  0.29871147],
       [ 0.55431633,  0.97571511],
       [ 0.58817449,  0.16531604],
       [ 0.24618851,  0.77734998],
       [ 0.39838626,  0.3413783 ],
       [ 0.8067798 ,  0.47410285],
       [ 0.3018356 ,  0.10023668],
       [ 0.48963439,  0.0601817 ],
       [ 0.78128715,  0.86172031],
       [ 0.44997697,  0.07087161],
       [ 0.83324041,  0.88279563],
       [ 0.67667458,  0.39383999],
       [ 0.08662906,  0.44005057],
       [ 0.98071847,  0.35073204],
       [ 0.56642842,  0.03235092],
       [ 0.20767939,  0.72556601],
       [ 0.09560867,  0.35348974],
       [ 0.06252147,  0.64106041],
       [ 0.02578202,  0.77158905],
       [ 0.33412694,  0.67708058],
       [ 0.5568066 ,  0.48587249],
       [ 0.84593942,  0.81212913],
       [ 0.62675422,  0.07599671],
       [ 0.59986361,  0.02833285],
       [ 0.21063615,  0.43350702],
       [ 0.25391483,  0.14347805],
       [ 0.65197371,  0.80803707],
       [ 0.32891677,  0.00175475],
       [ 0.52317395,  0.09622154],
       [ 0.12471656,  0.42167502],
       [ 0.45269629,  0.23511398],
       [ 0.99259586,  0.95630117],
       [ 0.39922883,  0.37148724],
       [ 0.06191172,  0.49132007],
       [ 0.29296126,  0.26750922],
       [ 0.55227183,  0.57628033],
       [ 0.74012728,  0.52004533],
       [ 0.3184045 ,  0.97886908],
       [ 0.49385818,  0.66074063],
       [ 0.62866864,  0.84624235],
       [ 0.7531463 ,  0.0871436 ],
       [ 0.69388733,  0.42287582],
       [ 0.13688053,  0.04140649]]), '__header__': 'MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Fri Sep  4 01:24:06 2015', '__globals__': []}
WARNING: pylab import has clobbered these variables: ['pylab', 'f', 'random', 'histogram']
`%matplotlib` prevents importing * from pylab and numpy

In [32]:
#

In [ ]: