1 条题解
-
0チルノ (9Cirno) LV 7 MOD Baka tayz @ 2024-05-09 17:22:20
\[\text{关于方差}\]
\[
\begin{aligned}
S^2 & = \frac{1}{n} \sum^{n}_{i = 1}(x_i - \overline{x})^2 \cr
& = \frac{1}{n} \sum^{n}_{i = 1}(x_i^2 - 2x_i\overline{x} + \overline{x}^2) \cr
& = \frac{1}{n} (\sum^{n}_{i = 1}x_i^2 - 2\overline{x}\sum^{n}_{i = 1}{x_i} + n\overline{x}^2) \cr
& = \frac{1}{n} (\sum^{n}_{i = 1}x_i^2 - 2n\overline{x}^2 + n\overline{x}^2) \cr
& = \frac{1}{n} (\sum^{n}_{i = 1}x_i^2 - n\overline{x}^2) \cr
& = \frac{1}{n} \sum^{n}_{i = 1}x_i^2 - \overline{x}^2 \cr
\end{aligned}
\]
由上可得,我们只需要维护一个区间和以及一个区间平方和即可。
- 1