関数calculate_average マニュアル

(The documentation of function calculate_average)

Last Update: 2025/8/7


◆機能・用途(Purpose)

実数値配列の要素\(d_1,\cdots,d_N\)の平均値 \[\begin{equation} \bar{d}=\frac{1}{N}\sum_{i=1}^Nd_i \label{eq.average} \end{equation}\] を計算する。
Calculate the average (eq. \ref{eq.average}) of the components of an array of real numbers \(d_1,\cdots,d_N\).


◆形式(Format)

#include <statistics.h>
inline double calculate_average(const int N,const double ∗d)


◆引数(Arguments)

N データサンプル数\(N\)。
The number of data samples \(N\).
d 実数値\(d_1,\cdots,d_N\)を並べた配列。
An array composed of the real numbers \(d_1,\cdots,d_N\).


◆戻り値(Return value)

(\ref{eq.average})式で計算した平均値。
The average calculated with eq. (\ref{eq.average}).


◆使用例(Example)

const int N=5;
const double d[]={1.2,3.4,5.6,7.8,9.0};
double a=calculate_average(N,d);


◆検証(Validation)

上の「使用例」の計算をこの関数を用いて行い、 正しい結果(5.4)が得られることを確認した。
A calculation of the “Example” above using this function yielded a correct result (5.4).