def linregress_array(posterior):
"""perform linear regression on the posterior matrix, and return the slope, intercept, and R^2 value"""
mode_pth = get_mode_pth_from_array(posterior)
y = mode_pth
x = np.arange(len(y))
x = x[~np.isnan(y)]
y = y[~np.isnan(y)]
if len(y) > 0:
slope, intercept, rvalue, pvalue, stderr = stats.linregress(x, y)
return slope, intercept, rvalue**2
else:
return np.nan, np.nan, np.nan
评论列表
文章目录