How does function std process complex numbers

43 ビュー (過去 30 日間)
JFz
JFz 2019 年 7 月 12 日
コメント済み: Rik 2022 年 2 月 14 日
In function S = std(A), there are complex numbers in matrix A. How does std calculate on complex numbers?
Thanks

採用された回答

David Goodmanson
David Goodmanson 2019 年 7 月 12 日
編集済み: David Goodmanson 2019 年 7 月 12 日
Hi JFz,
First of all, for a matrix the std is calculated independently for each column, as is true of many Matlab functions. For each column, std subtracts off the mean value as a complex calculation, then takes the absolute values of deviations from the mean and does the standard std calculation on those. For a vector of length N,
stand_dev = sqrt(sum(abs(r-mean(r)).^2)/(N-1))
  2 件のコメント
JFz
JFz 2019 年 7 月 15 日
Thank you so much!
Walter Roberson
Walter Roberson 2019 年 7 月 15 日
Which is to say that it does not do anything special for complex numbers.

サインインしてコメントする。

その他の回答 (1 件)

John D'Errico
John D'Errico 2019 年 7 月 15 日
編集済み: John D'Errico 2019 年 7 月 15 日
std uses the formula that is given by David, which is just the standard fornula, with no difference for complex inputs. But just to add a couple of useful formulas that apply for complex arguments:
var(V) = var(real(V)) + var(imag(V))
std(V) = sqrt(std(real(V))^2 + std(imag(V))^2 )
For example:
V = rand(1,5) + rand(1,5)*i;
var(V)
ans =
0.20393
var(real(V)) + var(imag(V))
ans =
0.20393
std(V)
ans =
0.45159
sqrt(std(real(V))^2 + std(imag(V))^2 )
ans =
0.45159
  1 件のコメント
Rik
Rik 2022 年 2 月 14 日
Comment posted as flag by @Paramonte:
Nice!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by