フィルターのクリア

HELP ME PLEASE with this geometric mean

1 回表示 (過去 30 日間)
IANC Cristian Gabriel
IANC Cristian Gabriel 2020 年 10 月 31 日
コメント済み: Bruno Luong 2020 年 10 月 31 日
how can I make the geometric mean in a matrix of 20x15 with only the positive numbers?

回答 (2 件)

Bruno Luong
Bruno Luong 2020 年 10 月 31 日
編集済み: Bruno Luong 2020 年 10 月 31 日
Assuming A is the vector of your data
geomean = exp(mean(log(A)))

Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
You can do it like this
x = randn(20, 15);
x_positive = x(x>0);
geo_mean = prod(x_positive)^(1/numel(x_positive))
  1 件のコメント
Bruno Luong
Bruno Luong 2020 年 10 月 31 日
Careful about overflow with prod
x=10*ones(1,1000)

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

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by