Ejemplo n.º 1
0
        problem.update_cell(candidate)
        currents_newdt = currents_given_v(v_newdt, t_newdt, problem.cell.soma, channel_list, ion_list, celsius)

        # convert units
        dvdt_sc, i_inj_sc, currents_sc, Cm, _ = convert_units(problem.cell.soma.L, problem.cell.soma.diam,
                                                              problem.cell.soma.cm, dvdt_newdt,
                                                              i_newdt, currents_newdt)

        # linear regression
        weights, residual, y, X = linear_regression(dvdt_sc, i_inj_sc, currents_sc, i_pas=0, Cm=Cm)

        # plots
        #plot_fit(y, X, weights, t_newdt, channel_list)

        # compute error
        error_traces[i, j] = rms(y, np.sum(np.array(currents), 0))

        error_tmp = [rms(weights_model[k], weights[k]) for k in range(len(weights_model))]
        error_weights[i, j] = np.mean(error_tmp)


# compute mean error of all models
print
for j, dt in enumerate(dts):
    print 'Mean error in the weights with dt = '+str(dt)+' ms: ' \
          + str(np.mean(error_weights[:, j]))

print
for j, dt in enumerate(dts):
    print 'Mean error in the fit with dt = '+str(dt)+' ms: ' \
          + str(np.mean(error_traces[:, j]))
Ejemplo n.º 2
0
 def get_mean_rms_candidate_variables(self, candidate, optimal_candidate):
     return np.mean(np.array([rms(candidate[k], optimal_candidate[k])
                              for k in range(len(optimal_candidate))]))