標準偏差(std)の重みについて

4 views (last 30 days)
朋貴 熊田
朋貴 熊田 on 15 May 2022
Commented: 朋貴 熊田 on 16 May 2022
stdを使用する際に値が0である行列を数えないで正規化したいのですが、何か良い方法はありますか?
ご教授お願いいたします。
  2 Comments
Hernia Baby
Hernia Baby on 15 May 2022
0を除外するという認識でよろしいですか?
朋貴 熊田
朋貴 熊田 on 15 May 2022
はいその認識で間違えないです

Sign in to comment.

Accepted Answer

Hernia Baby
Hernia Baby on 16 May 2022
std のオプションにNaNを除外する機能がありますので、0をNaNにしましょう
まずはデータを用意します
A = randi([-5 5],9)
A = 9×9
1 4 -4 -3 5 3 2 0 -2 3 -5 3 4 -5 1 4 -5 1 -1 -3 -3 3 -4 -1 1 -1 2 0 -3 2 5 0 -1 3 5 2 -5 1 -3 2 -4 1 -3 2 -2 3 -2 0 3 4 -2 4 -1 1 2 -1 -3 -1 4 4 2 1 -1 -5 4 5 -1 -1 -5 -1 1 -3 4 -2 3 0 -2 -5 -3 -5 0
0をNaNにします
A(A==0) = nan()
A = 9×9
1 4 -4 -3 5 3 2 NaN -2 3 -5 3 4 -5 1 4 -5 1 -1 -3 -3 3 -4 -1 1 -1 2 NaN -3 2 5 NaN -1 3 5 2 -5 1 -3 2 -4 1 -3 2 -2 3 -2 NaN 3 4 -2 4 -1 1 2 -1 -3 -1 4 4 2 1 -1 -5 4 5 -1 -1 -5 -1 1 -3 4 -2 3 NaN -2 -5 -3 -5 NaN
NaNを除外して計算します
std(A,'omitnan')
ans = 1×9
3.5757 3.1535 3.5857 2.8284 4.1036 3.1667 2.7386 3.4200 1.9821
  1 Comment
朋貴 熊田
朋貴 熊田 on 16 May 2022
ご回答ありがとうございます。

Sign in to comment.

More Answers (0)

Categories

Find more on フィルター バンク in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!