Exemplo n.º 1
0
traces = fit.extract()
a = traces['a']
# b = traces['b']
sig_e = traces['sig_e']
lam = traces['lambda']
s = traces['s']
x = traces['x']
# c = traces['c']
# d = traces['d']


plt.plot(np.mean(s,axis=0))
plt.show()


plot_trace(a, 2, 1, 'a')
plot_trace(sig_e, 2, 2, 'sig_e')
plt.show()
#
# plt.subplot(2,5,1)
# plt.hist(c[:,0])
# plt.title('Coeff of ua')
#
# plt.subplot(2,5,2)
# plt.hist(c[:,1])
# plt.title('Coeff of ud')
#
# plt.subplot(2,5,3)
# plt.hist(c[:,2])
# plt.title('Coeff of up')
#
Exemplo n.º 2
0
print('Model fit of hmc estimate = ', MF_hmc)

f_coef_traces = traces['f_coefs']
b_coef_traces = traces['b_coefs']

f_mean = np.mean(f_coef_traces, 0)
b_mean = np.mean(b_coef_traces, 0)

plt.subplot(1, 1, 1)
plt.plot(y_val, linewidth=0.5)
plt.plot(yhat_mean, linewidth=0.5)
plt.ylim((-2, 2))
plt.legend(('y val', 'y hat'))
plt.show()

plot_trace(f_coef_traces[:, 0], 4, 1, 'f[0]')
plot_trace(f_coef_traces[:, 1], 4, 2, 'f[2]')
plot_trace(b_coef_traces[:, 0], 4, 3, 'b[0]')
plot_trace(b_coef_traces[:, 1], 4, 4, 'b[1]')
plt.show()

# now plot the bode diagram
f_true = data["f_true"]
b_true = data["b_true"]

Ts = 0.1
w_res = 500
w_plot = np.logspace(-3, np.log10(10 * 3.14), w_res)

F_ML = data['f_ml']
B_ML = data['b_ml']
Exemplo n.º 3
0
r_mean = np.mean(r_traces, 0)
LQ_mean = np.mean(LQ_traces, 0)

h_upper_ci = np.percentile(h_traces, 97.5, axis=0)
h_lower_ci = np.percentile(h_traces, 2.5, axis=0)

plt.subplot(1, 1, 1)
plt.plot(y_est, linewidth=0.5)
plt.plot(yhat_mean, linewidth=0.5)
plt.plot(yhat_upper_ci, '--', linewidth=0.5)
plt.plot(yhat_lower_ci, '--', linewidth=0.5)
plt.title('measurement estimates')
plt.legend(('true', 'mean', 'upper CI', 'lower CI'))
plt.show()

plot_trace(A_traces[:, 1, 0], 4, 1, 'A[2,2]')
plot_trace(C_traces[:, 1], 4, 2, 'C[1]')
plot_trace(D_traces, 4, 3, 'D')
plot_trace(r_traces, 4, 4, 'r')
plt.show()
#
# plt.subplot(1,1,1)
# plt.plot(A_traces[:,1,0],A_traces[:,1,1],'o')
# plt.title('samples pairs plot')
# plt.show()

# BODE diagram
# B_mean = np.array([[0],[1]])
A_true = data['A_true']
B_true = data['B_true']
C_true = data['C_true']
Exemplo n.º 4
0
z = traces['h'][:, :, :no_obs]

theta_mean = np.mean(theta, 0)
z_mean = np.mean(z, 0)

# LQ = traces['LQ']
# LQ_mean = np.mean(LQ,0)
# LR = traces['LR']
# LR_mean = np.mean(LR,0)
#
# R = np.matmul(LR_mean, LR_mean.T)
# Q = np.matmul(LQ_mean, LQ_mean.T)

print('mean theta = ', theta_mean)

plot_trace(theta[:, 0], 3, 1, 'Jr')
plot_trace(theta[:, 1], 3, 2, 'Jp')
plot_trace(theta[:, 2], 3, 3, 'Km')
plt.show()

plot_trace(theta[:, 3], 3, 1, 'Rm')
plot_trace(theta[:, 4], 3, 2, 'Dp')
plot_trace(theta[:, 5], 3, 3, 'Dr')
plt.show()

plt.subplot(2, 2, 1)
plt.plot(y[0, :])
plt.plot(z_mean[0, :])
plt.xlabel('time')
plt.ylabel(r'arm angle $\theta$')
plt.legend(['Measurements', 'mean estimate'])
Exemplo n.º 5
0
a_coef_traces = traces['a_coefs']
b_coef_traces = traces['b_coefs']
shrinkage_param = traces["shrinkage_param"]
shrinkage_param_mean = np.mean(shrinkage_param, 0)

a_coef_mean = np.mean(a_coef_traces, 0)
b_coef_mean = np.mean(b_coef_traces, 0)

plt.subplot(1, 1, 1)
plt.plot(y_val, linewidth=0.5)
plt.plot(yhat_mean, linewidth=0.5)
plt.plot(yhat_upper_ci, '--', linewidth=0.5)
plt.plot(yhat_lower_ci, '--', linewidth=0.5)
plt.show()

plot_trace(a_coef_traces[:, 0], 4, 1, 'a[0]')
plot_trace(a_coef_traces[:, 1], 4, 2, 'a[2]')
plot_trace(b_coef_traces[:, 0], 4, 3, 'b[0]')
plot_trace(b_coef_traces[:, 1], 4, 4, 'b[1]')
plt.show()

b_true = data["b_true"]
a_true = data["a_true"]
Ts = 1.0

w_res = 300
w_plot = np.logspace(-2, np.log10(3.14), w_res)
# plot_dbode(b_coef_traces,a_coef_traces,b_true,a_true,Ts,w_plot)

# a_ML = data['a_ML']
# b_ML = data['b_ML']
Exemplo n.º 6
0
stan_data = {
    'N':N,
    'y':y,
}

fit = model.sampling(data=stan_data)

traces = fit.extract()

z = traces['z']
z_mean = np.mean(z,0)
# z_upper = np.percentile(z,)

a = traces['a']
a_mean = np.mean(a,0)
r = traces['r']
q = traces['q']

plot_trace(a,3,1,'a')
plot_trace(r,3,2,'r')
plot_trace(q,3,3,'q')
plt.show()

plt.subplot(1,1,1)
plt.plot(x)
plt.plot(z_mean,'--')
plt.plot(y,'o')
plt.show()