In [1]:
%matplotlib inline
import h5py
import matplotlib.pyplot as plt
import numpy as np
from sklearn import mixture
from mvn import MVN
In [2]:
# constants
RESAMPLE = 6
GMM_DYN_COMPONENTS = 10
INITIAL_VARIANCE_RATIO = 0.1
In [3]:
# load data
f = h5py.File( 'data.h5', 'r' )
x = f[ 'x' ]
x = x[ ::RESAMPLE ]
In [4]:
# plot data
fig, ax1 = plt.subplots()
ax1.plot( x[ :,1 ], 'g-' )
ax1.set_ylabel( r'$\theta$' )
ax2 = ax1.twinx()
ax2.plot( x[ :, 5 ], 'b' )
ax2.set_ylabel( '$F$' )
Out[4]:
In [5]:
g1 = MVN( x[ 10, 1:], np.array( [ 0.5, 0.5, 0.5, 0.5, 0.5 ] ) )
In [6]:
x_dyn = np.column_stack( ( x[ 1:, 1:5 ], x[ :-1, 1:6 ] ) )
In [7]:
gmm = mixture.GMM( n_components=GMM_DYN_COMPONENTS, covariance_type='full' )
gmm.fit( x_dyn )
Out[7]:
In [8]:
g1 = MVN( x_dyn[ 13, :], np.diag( x_dyn[ 13, :] * INITIAL_VARIANCE_RATIO ) )
In [10]:
g = g1.cond( x_dyn[ 13,4: ] )
In [ ]: