我有一个数据框,其中每一行都有一个特定的权重需要在均值计算中加以考虑。我喜欢seaborn factorplots及其自举95%置信区间,但无法让seaborn接受新的加权均值估计器。
以下是我想要做的示例。
tips_all = sns.load_dataset("tips")
tips_all["weight"] = 10 * np.random.rand(len(tips_all))
sns.factorplot("size", "total_bill",
data=tips_all, kind="point")
# here I would like to have a mean estimator that computes a weighted mean
# the bootstrapped confidence intervals should also use this weighted mean estimator
# something like (tips_all["weight"] * tips_all["total_bill"]).sum() / tips_all["weight"].sum()
# but on bootstrapped samples (for the confidence interval)