def build_model_poly(detection_pairs, beacon_sdoa, nominal_sample_rate, deg=2):
if len(detection_pairs) < deg + 1:
# not enough beacon transmissions
return None
soa0 = np.array([d[0].soa for d in detection_pairs])
soa1 = np.array([d[1].soa for d in detection_pairs])
soa1at0 = soa1 + np.array(beacon_sdoa)
coef = np.polyfit(soa1at0, soa0, deg)
fit = np.poly1d(coef)
# residuals = soa0 - fit(soa1at0)
# print(np.mean(residuals))
def evaluate(det0, det1):
return (det0.soa - fit(det1.soa)) / nominal_sample_rate
return evaluate
评论列表
文章目录