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?

z-score

Posted at

z-score:データの平均からの偏差を標準偏差で割ったものです。具体的には、以下のように計算されます:


data = np.array([10, 20, 30, 40, 50])

def zscore(x):
    xmean = x.mean()
    xstd  = np.std(x)
    zscore = (x - xmean) / xstd
    return zscore

zscore(data)

xmean = data.mean()
# xmean = (10 + 20 + 30 + 40 + 50) / 5 = 30

xstd = np.std(data)
# xstd = sqrt(((10-30)^2 + (20-30)^2 + (30-30)^2 + (40-30)^2 + (50-30)^2) / 5)
# xstd = sqrt((400 + 100 + 0 + 100 + 400) / 5)
# xstd = sqrt(2000 / 5)
# xstd = sqrt(400)
# xstd = 20

zscore = (data - xmean) / xstd
# zscore = ([10, 20, 30, 40, 50] - 30) / 20
# zscore = [-20, -10, 0, 10, 20] / 20
# zscore = [-1, -0.5, 0, 0.5, 1]

この関数は、データ x の平均 xmean と標準偏差 xstd を計算し、各データポイントの平均からの偏差を標準偏差で割ることで標準スコアを求めています。標準スコアは、データが平均からどれだけ離れているかを示す指標です。

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?