メインコンテンツへスキップ
見出し画像
Photo byomori55

データ分析:公式集

    〈定義〉
    ○ 平均    x ‾=x1+x2+⋯+xnn\overline{\, x \,} = \dfrac{x_1 + x_2 + \cdots + x_n}{n}
    ○ 分散   Sx  2=(x1− x ‾)2+⋯+(xn− x ‾)2nS_x^{\; 2} = \dfrac{(x_1 - \overline{\, x \,})^2 + \cdots + (x_n - \overline{\, x \,})^2}{n}
    ○ 標準偏差 Sx=Sx  2 S_x = \sqrt{S_x^{\; 2} \, }
    ○ 共分散  Sxy=(x1− x ‾)(y1− y ‾)+⋯+(xn− x ‾)(yn− y ‾)nS_{xy} = \dfrac{(x_1 - \overline{\, x \,})(y_1 - \overline{\, y \,}) + \cdots + (x_n - \overline{\, x \,})(y_n - \overline{\, y \,})}{n}
    ○ 相関係数 r=SxySxSyr = \dfrac{S_{xy}}{S_x S_y}

    〈定理〉
    ○ 分散  Sx  2= x2 ‾− x ‾2S_x^{\; 2} = \overline{\, x^2 \,} - \overline{\, x \,}^2      … ①
    ○ 共分散 Sxy= xy ‾− x ‾⋅ y ‾S_{xy} = \overline{\, xy \,} - \overline{\, x \,} \cdot \overline{\, y \,}      … ②

    〈変換〉
    ○ x=cu+x0x = cu + x_0   で変換すると   x ‾=c  u ‾+x0\overline{\, x \,} = c \overline{\, u \,} + x_0    … ③
      ( ⇔u =x−x0c\Leftrightarrow \quad u = \dfrac{x - x_0}{c} )       Sx=∣c∣SuS_x = | c | S_u    … ④
    ○ x=cu+x0x = cu + x_0   で変換すると  Sxy=cd SuvS_{xy} = cd \, S_{uv}   … ⑤
      y=dv+y0y = dv + y_0        rxy=ruvr_{xy} = r_{uv} または rxy=−ruvr_{xy} = - r_{uv} … ⑥

    ◇      ◇      ◇

    ① Sx  2=(x1− x ‾)2+(x2− x ‾)2+⋯+(xn− x ‾)2nS_x^{\; 2} = \dfrac{(x_1 - \overline{\, x \,})^2 + (x_2 - \overline{\, x \,})^2 + \cdots + (x_n - \overline{\, x \,})^2}{n}
               ↓ (x1− x ‾)2=x1  2−2x1  x ‾+ x ‾2(x_1 - \overline{\, x \,})^2 = x_1^{\; 2} - 2 x_1  \overline{\, x \,} + \overline{\, x \,}^2
       =(x1  2+x2  2+⋯+xn  2)−2(x1+x2+⋯+xn) x ‾+n x ‾2n= \dfrac{(x_1^{\; 2} +x_2^{\; 2} + \cdots + x_n^{\; 2}) - 2(x_1 + x_2 + \cdots + x_n ) \overline{\, x \,} + n \overline{\, x \,}^2 }{n}
       =x1  2+x2  2+⋯+xn  2n−2 x ‾⋅ x ‾+ x ‾2 = \dfrac{x_1^{\; 2} +x_2^{\; 2} + \cdots + x_n^{\; 2} }{n} - 2 \overline{\, x \,} \cdot \overline{\, x \,} + \overline{\, x \,}^2 
       = x2 ‾− x ‾2= \overline{\, x^2 \,} - \overline{\, x \,}^2

    ② Sxy=(x1− x ‾)(y1− y ‾)+⋯+(xn− x ‾)(yn− y ‾)nS_{xy} = \dfrac{(x_1 - \overline{\, x \,})(y_1 - \overline{\, y \,}) + \cdots + (x_n - \overline{\, x \,})(y_n - \overline{\, y \,})}{n}
             ↓ (x1− x ‾)(y1− y ‾)=x1y1−x1  y ‾−y1  x ‾+ x ‾⋅ y ‾(x_1 - \overline{\, x \,})(y_1 - \overline{\, y \,}) = x_1 y_1 - x_1  \overline{\, y \,} - y_1  \overline{\, x \,}+ \overline{\, x \,} \cdot \overline{\, y \,}
       =(x1y1+⋯ )−(x1+⋯ ) y ‾−(y1+⋯ ) x ‾+n x ‾⋅ y ‾n= \dfrac{(x_1 y_1 + \cdots ) - (x_1 + \cdots ) \overline{\, y \,} - (y_1 + \cdots ) \overline{\, x \,} + n \overline{\, x \,} \cdot \overline{\, y \,} }{n}
       =x1y1+⋯+xnynn− x ‾⋅ y ‾− x ‾⋅ y ‾+ x ‾⋅ y ‾= \dfrac{x_1 y_1 + \cdots + x_n y_n }{n} - \overline{\, x \,} \cdot \overline{\, y \,} - \overline{\, x \,} \cdot \overline{\, y \,} + \overline{\, x \,} \cdot \overline{\, y \,}
       = xy ‾− x ‾⋅ y ‾= \overline{\, xy \,} - \overline{\, x \,} \cdot \overline{\, y \,}

    ③  x ‾=x1+x2+⋯+xnn\overline{\, x \,} = \dfrac{x_1 + x_2 + \cdots + x_n}{n}
               ↓ xi=cui+x0x_i = cu_i + x_0  で変換
       =(cu1+x0)+(cu2+x0)+⋯+(cun+x0)n = \dfrac{(c u_1 + x_0) + (c u_2 + x_0) + \cdots + (c u_n + x_0)}{n}
       =c u1+u2+⋯+unn+nx0n = c \, \dfrac{u_1 + u_2 + \cdots + u_n }{n} + \dfrac{n x_0 }{n}
       =c  u ‾+x0 = c \overline{\, u \,} + x_0

    ④ Sx  2=(x1− x ‾)2+⋯+(xn− x ‾)2nS_x^{\; 2} = \dfrac{(x_1 - \overline{\, x \,})^2 + \cdots + (x_n - \overline{\, x \,})^2}{n}
               ↓ ② より  x ‾=c  u ‾+x0\overline{\, x \,} = c \overline{\, u \,} + x_0
       ={(cu1+x0)−(c  u ‾+x0)}2+⋯+{(cun+x0)−(c  u ‾+x0)}2n = \dfrac{\{ (c u_1 + x_0 ) - (c \overline{\, u \,} + x_0 ) \}^2 + \cdots + \{ (c u_n + x_0 ) - (c \overline{\, u \,} + x_0 ) \}^2 }{n}
       =c2 (u1− u ‾)2+⋯+(un− u ‾)2n = c^2 \, \dfrac{(u_1 - \overline{\, u \,})^2 + \cdots + (u_n - \overline{\, u \,})^2}{n}
       =c2 Su  2 = c^2 \, S_u^{\; 2} より
      Sx=∣c∣SuS_x = | c | S_u

    ⑤  (xi− x ‾)(yi− y ‾) (x_i - \overline{\, x \,})(y_i - \overline{\, y \,})
           ↓ yi=dvi+y0y_i = dv_i + y_0  で変換すると  y ‾=d  v ‾+y0\overline{\, y \,} = d \overline{\, v \,} + y_0
       ={(cui+x0)−(c  u ‾+x0)}{(dvi+y0)−(d v ‾+y0)}= \{ (c u_i + x_0)-(c \overline{\, u \,} + x_0) \} \{ (d v_i + y_0)-(d \overline{\, v \,} + y_0) \}
       =cd (ui−  u ‾) (vi−  v ‾) = cd \, (u_i - \overline{\, u \,}) \, (v_i - \overline{\, v \,})  より
      Sxy=(x1− x ‾) (y1− y ‾)+⋯+(xn− x ‾) (yn− y ‾)nS_{xy} = \dfrac{(x_1 - \overline{\, x \,}) (y_1 - \overline{\, y \,}) + \cdots + (x_n - \overline{\, x \,}) (y_n - \overline{\, y \,}) }{n}
       =cd (u1− u ‾) (v1− v ‾)+⋯+(un− u ‾) (vn− v ‾)n = cd \, \dfrac{(u_1 - \overline{\, u \,}) (v_1 - \overline{\, v \,}) + \cdots + (u_n - \overline{\, u \,}) (v_n - \overline{\, v \,}) }{n}
       =cd Suv = cd \, S_{uv}

          ┌ ⑤ → ┐
    ⑥ rxy=SxySxSyr_{xy} = \dfrac{S_{xy}}{S_x S_y} =cd Suv∣c∣Su ∣d∣Sv = \dfrac{cd \, S_{uv}}{| c | S_u \, | d | S_v} =cd∣cd∣ SuvSuSv = \dfrac{cd}{| cd |} \, \dfrac{S_{uv}}{S_u S_v} =cd∣cd∣ ruv = \dfrac{cd}{| cd |} \, r_{uv}
          └ ④ → ┘
       つまり  c , dc \, , \, dが同符号のとき rxy=ruvr_{xy} = r_{uv}
            c , dc \, , \, dが異符号のとき rxy=−ruvr_{xy} = - r_{uv}

     具体例は こちら をどうぞ。

    ◇      ◇      ◇

        〜 AIは相関で動く 〜
      ▷ 因果 と 相関
      ▷ データ分析:公式集
      ▷ 相関係数を求めてみよう
      ▷ 入試で2科目の得点が逆相関?

     
     
    情報科・数学科教員にして   作家・旅人・芸人 AI評論家・火山ハンター

    あなたへのおすすめ