Weighted Means

Calculates the weighted geometric, arithmetic, or harmonic means of input vectors.
ダウンロード: 1.4K
更新 2008/3/19

ライセンスの表示

This function calculates the weighted arithmetic, harmonic, or geometric mean of a set of input value arrays and weight arrays.

There are really two modes of operation:
1) If there is only one input value array and weight array, the weighted mean is calculated across all elements in this array. The user can specify which dimension to calculate the weighted mean across, or even specify 'all' in which case the arrays are flattened and only a scalar value is returned.
2) If there are multiple input value arrays and weight arrays, the element-by-element weighted mean is output across the N input value and weight arrays.

Examples:
Mode 1:
>> scalarMean = weighted_mean('harmonic',[1 2 3],[0.2, 0.3, 0.2]); %the output is single scalar value

>> arrayMean = weighted_mean('arithmetic',[1 2 3],[0.2, 0.3, 0.2],1); %the output is a vector of size (3x1)

Mode 2:
>> arrayMean = weighted_mean('geometric',[1,2,3],[4,5,6],[0.2,0.3,0.2],[0.2,0.1,0.1]); %the output is a vector of size (1x3)

引用

Anthony Kendall (2024). Weighted Means (https://www.mathworks.com/matlabcentral/fileexchange/19254-weighted-means), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2007a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersTime Series についてさらに検索
タグ タグを追加

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0