Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.3 - 日本語

Change language to:
English - Français - Português

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab help >> Linear Algebra > lsq

lsq

線形最小二乗問題.

呼び出し手順

X=lsq(A,B [,tol])

パラメータ

A

実数または複素数の (m x n) 行列

B

実数または複素数の (m x p) 行列

tol

Aの実効ランクを定義するために使用される正のスカラー (Aのピボット操作付きQR分解における最前部にある部分三角行列R11の次数として 定義され,条件数の推定値は<= 1/tolとなります. tolのデフォルト値は sqrt(%eps)に設定されます )

X

実数または複素数の (n x p) 行列

説明

X=lsq(A,B) は方程式 A*X=Bの 最小二乗解の最小ノルムを計算します. 一方, X=A \ Bは 各列に最大rank(A)個の非ゼロ要素を有する最小二乗解を計算します.

参考文献

lsq 関数はLApack 関数 DGELSY (実行列の場合)および ZGELSY (複素行列の場合)に基づいています.

//Build the data
x=(1:10)';

y1=3*x+4.5+3*rand(x,'normal');
y2=1.8*x+0.5+2*rand(x,'normal');
plot2d(x,[y1,y2],[-2,-3])
//Find the linear regression 
A=[x,ones(x)];B=[y1,y2];
X=lsq(A,B);

y1e=X(1,1)*x+X(2,1);
y2e=X(1,2)*x+X(2,2);
plot2d(x,[y1e,y2e],[2,3])

//Difference between lsq(A,b) and A\b
A=rand(4,2)*rand(2,3);//a rank 2 matrix
b=rand(4,1);
X1=lsq(A,b)
X2=A\b
[A*X1-b, A*X2-b] //the residuals are the same

参照

<< linsolve Linear Algebra lu >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Oct 05 12:12:40 CEST 2011