第1回の練習問題¶

以下のデータの平均値、中央値、分散、標準偏差、第一四分位数、第三四分位数、四分位範囲を求めなさい。
L = [56,57,92,73,65,24,37,91,79]

In [1]:
# データ
L = [56,57,92,73,65,24,37,91,79]
In [2]:
import numpy as np

# 平均値
np.average(L)
Out[2]:
63.77777777777778
In [3]:
# 平均値
sum(L)/len(L)
Out[3]:
63.77777777777778
In [4]:
# 中央値
np.median(L)
Out[4]:
65.0
In [5]:
# 分散
np.var(L)
Out[5]:
473.5061728395062
In [6]:
# 標準偏差
np.std(L)
Out[6]:
21.76019698531027
In [7]:
from scipy import stats
# 第一四分位数
stats.scoreatpercentile(L,25)
Out[7]:
56.0
In [8]:
# 第三四分位数
stats.scoreatpercentile(L,75)
Out[8]:
79.0
In [9]:
# 四分位範囲
a = stats.scoreatpercentile(L,75)
b = stats.scoreatpercentile(L,25)
a - b
Out[9]:
23.0