#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun  6 17:25:51 2017

@author: jonny
"""
import numpy as np
import matplotlib.pyplot as plt
import pickle
with open('c10p1.pickle', 'rb') as f:
    data = pickle.load(f)

#Takes values out of dictionary    
values = data['c10p1']

#Create Array for x and y values
x_values = []
y_values = []

#Seperate values in matrix to arrays
for x in range(100):
    x_values.append(values[x][0])
    y_values.append(values[x][1])
    
x_values = np.array(x_values)
y_values = np.array(y_values)

plt.figure(1)
plt.plot(x_values,y_values,"*")
plt.show

#Find mean values of X
x_mean = np.mean(x_values)
y_mean = np.mean(y_values)

#Calculate 0,0 centerd values
x_norm = []
y_norm = []

for x in range(100):
    x_norm.append(x_values[x]-x_mean)
    y_norm.append(y_values[x]-y_mean)
    
plt.figure(2)  
plt.plot(x_norm, y_norm, "*")
plt.show

#Implementing Update Rule
alpha = 1
factor = 0.01

w_1 = w_0 + factor * (vu - aplha * v*v*w_0)

    