0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pythonで学ぶ統計入門1

Posted at

統計学の復習用に記載

▶️ 記述統計ってなに?

記述統計は「データをぱっと見ただけで分かるように整理する技術」です。
データをまとめたり、戦略を立てる基盤になります!


▶️ Pythonでサクッと計算

【例題データ】

import numpy as np
import pandas as pd

# サンプルデータ
data = [10, 20, 30, 40, 50]

1. 平均 (Mean)

mean = np.mean(data)
print("平均:", mean)
  • 全体のまとまり。
  • 値が大きければ、全体的に高い値と言えます。

2. 中央値 (Median)

median = np.median(data)
print("中央値:", median)
  • 中間の値。
  • 特に偏ったデータに対して、平均よりも実態を表しやすいです。

3. 最頻値 (Mode)

mode = pd.Series(data).mode().values[0]
print("最頻値:", mode)
  • 最もよく出る値。
  • みんなが好きなものやよく選ばれる値のイメージ!

4. 分散 (Variance)

variance = np.var(data, ddof=1)
print("分散:", variance)
  • どれだけばらついているかの指標。
  • 値が大きいと、データにばらつきが大きいと言えます。

5. 標準偏差 (Standard Deviation)

std_dev = np.std(data, ddof=1)
print("標準偏差:", std_dev)
  • 分散をもっと直感的にわかりやすくしたもの!
  • 値が大きければ、平均に対して大きく変動していることがわかります。

6. 相関係数 (Correlation Coefficient)

# 別のデータを作成
data2 = [15, 25, 35, 45, 55]
correlation = np.corrcoef(data, data2)[0, 1]
print("相関係数:", correlation)
  • お互いの関連度。
  • +1に近いほど、両者が同じ方向に変化する。-1だと逆方向に変化!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?