均值的效应量
许多由风投支持的公司会经历多轮融资。通常,第 2 轮会比第 1 轮更大。那么,轮次对平均融资额的影响有多大?您可以用 Cohen's d 来量化这一点。
回顾一下,要计算 Cohen's d,您需要先计算合并标准差。其公式为:

随后,Cohen's d 的计算如下:

我们已经为您加载了一个包含风投投资数据的 DataFrame(investments_df),以及 pandas(导入为 pd)、NumPy(导入为 np)和 SciPy 中的 stats。列 funding_total_usd 表示该轮中获得的总融资额。
本练习是课程的一部分
Python 推断基础
练习说明
- 分别筛选出
investments_df中funding_rounds为 1 和 2 的数据。 - 分别计算每一轮的标准差和样本量。
- 计算两轮之间的合并标准差。
- 使用刚才得到的量来计算 Cohen's d。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Select all investments from rounds 1 and 2 separately
round1_df = investments_df[____['funding_rounds'] == ____]
round2_df = investments_df[____['funding_rounds'] == ____]
# Calculate the standard deviation of each round and the number of companies in each round
round1_sd = ____.std()
round2_sd = ____.std()
round1_n = ____.shape[0]
round2_n = ____.shape[0]
# Calculate the pooled standard deviation between the two rounds
pooled_sd = np.sqrt(((____ - 1) * ____ ** 2 + (____ - 1) *____ ** 2) / (____ + ____ - 2))
# Calculate Cohen's d
d = (____.mean() - ____.mean()) / ____