関数determination_coefficient マニュアル

(The documentation of function determination_coefficient)

Last Update: 2023/2/28


◆機能・用途(Purpose)

データの直線フィッティングにおける決定係数を計算する。
Calculate the coefficient of determination for the straight line fitting of data.

決定係数は以下のように定義される。 N個の独立変数xと従属変数yの組 (x,y)=(x1,y1),,(xN,yN) が与えられており、 これらを直線y=ax+b (a, b: 定数)でフィットした結果も 得られているものとする。 またy1,,yNの平均値を (1)y¯=1Ni=1Nyi とする。このとき、決定係数は (2)R2=1i=1N(yiaxib)2i=1N(yiy¯)2 で定義される。
The coefficient of determination is determined as follows. Let (x,y)=(x1,y1),,(xN,yN) be N data points of an independent variable x and a dependent variable y. Let the result of fitting these data by a straight line y=ax+b, where a and b are constants, are obtained in advance to the function call. Let y¯ be the average of y1,,yN defined by Eq. (1). Then the coefficient of determination is defined by Eq. (2).


◆形式(Format)

#include <fitting.h>
inline double determination_coefficient
(const int N,const double ∗x,const double ∗y, const double a,const double b)


◆引数(Arguments)

N データ点数N
The number of data points N.
x 独立変数xの値x1,,xNを並べた配列。
An array composed of the values, x1,,xN, of the independent variable x.
y 従属変数yの値y1,,yNを並べた配列。
An array composed of the values, y1,,yN, of the dependent variable y.
a データを直線y=ax+bでフィットしたときの傾きa。 傾きは関数fitting_line2を用いて 求めることを想定している。
The slope, a, of the straight line y=ax+b that best fits the data. The slope is assumed to have been determined by function fitting_line2.
b データを直線y=ax+bでフィットしたときの切片b。 切片は関数fitting_line2を用いて 求めることを想定している。
The intercept, b, of the straight line y=ax+b that best fits the data. The intercept is assumed to have been determined by function fitting_line2.


◆戻り値(Return value)

決定係数(2式)の値。
The value of the coefficient of determination (Eq. 2).


◆使用例(Example)

double x[]={1.0,2.0,3.0,4.0,5.0};
double y[]={1.1,2.1,3.4,4.5,5.5};
double ∗line=fitting_line2(5,x,y);
double R2=determination_coefficient(5,x,y,line[0],line[1]);