def fit_lenscale(df, lenscalepool): """searches over the lenscales in lenscale pool for the ls that best predicts drilling behavior given the samples in the trial for each trial (row) in the df""" print 'workerid: ' + df.workerid.iat[0] X = np.linspace(0, 1, 1028) trialFits = [get_experimentError(df, lenscale, X) for lenscale in lenscalepool] trialFits = np.asarray(trialFits) xerr = trialFits[:,:,0] mu_xerr_byLenscale = xerr.mean(axis=1) iBestLen = mu_xerr_byLenscale.argmin() fit_lenscale = lenscalepool[iBestLen] return fit_lenscale
def single_exp_err(df, lenscale): print 'workerid: ' + df.workerid.iat[0] X = np.linspace(0, 1, 1028) expfits = get_experimentError(df, lenscale, X) return expfits[:, 0].mean()