文档

lsqnonneg

解决非负线性最小二乘问题问题

Solve nonnegative least-squares curve fitting problems of the form

最小 X C Å X - d 2 2 ,,,, 在哪里 X 0。

句法

x = lsqnonneg(c,d)
x =lsqnonneg(C,d,options)
x =lsqnonneg(problem)
[x,resnorm,残留] = lsqnonneg(___
[x,resnorm,残留,出口,输出] = lsqnonneg(___
[x,重新塑料,残留,出口,输出,lambda] = lsqnonneg(___

Description

例子

X= lsqnonneg(C,,,,d返回向量Xthat minimizesnorm(C*x-d)约束x≥0。ArgumentsCandd必须是真实的。

例子

X= lsqnonneg(C,,,,d,,,,选项用结构中指定的优化选项最小化选项。利用最佳集to set these options.

X= lsqnonneg(问题找到最小问题,在那里问题是一个结构。

例子

[[X,,,,resnorm,,,,剩余的] = lsqnonneg(___,,,,for any previous syntax, additionally returns the value of the squared 2-norm of the residual,norm(c*x-d)^2,,,,and returns the residuald-C*x

[[X,,,,resnorm,,,,剩余的,,,,出口,,,,输出] = lsqnonneg(___additionally returns a value出口描述了出口条件lsqnonneg和一个结构输出有关优化过程的信息。

例子

[[X,,,,resnorm,,,,剩余的,,,,出口,,,,输出,,,,兰姆达] = lsqnonneg(___另外返回Lagrange乘数向量兰姆达

Examples

collapse all

将非负解决方案计算到线性最小二乘问题,并将结果与​​无约束问题的解决方案进行比较。

准备Cmatrix andd问题向量

C = [0.0372 0.2869 0.6861 0.7071 0.6233 0.6245 0.6344 0.6170];d = [0.8587 0.1781 0.0747 0.8405];

Compute the constrained and unconstrained solutions.

x = lsqnonneg(c,d)
x =0 0.6929
xunc =C\d
xunc =-2.5627 3.1108

所有条目Xare nonnegative, but some entries inXuncare negative.

计算两种溶液的残差规范。金宝搏官方网站

约束_norm = norm(c*x -d)
constrained_norm = 0.9118
uncontained_norm = norm(c*xunc -d)
uncontained_norm = 0.6674

无约束的解决方案具有较小的残留规范,因为约束只能增加残余规范。

设置展示option to'final'查看输出lsqnonneg完成。

创建选项。

选项=最佳集('Display',,,,'final');

准备Cmatrix andd问题向量

C = [0.0372 0.2869 0.6861 0.7071 0.6233 0.6245 0.6344 0.6170];d = [0.8587 0.1781 0.0747 0.8405];

称呼lsqnonneg与选项结构。

x = lsqnonneg(c,d,选项);
优化终止。

称呼lsqnonneg使用输出以获得解决方案,残留规范和残留矢量。

准备Cmatrix andd问题向量

C = [0.0372 0.2869 0.6861 0.7071 0.6233 0.6245 0.6344 0.6170];d = [0.8587 0.1781 0.0747 0.8405];

获取解决方案和剩余信息。

[x,resnorm,残留] = lsqnonneg(c,d)
x =0 0.6929
RESNORM = 0.8315
剩余的=0.6599 -0.3119 -0.3580 0.4130

验证返回的残差标准是返回的残差矢量规范的平方。

规范(残留)^2
ans = 0.8315

Request all output arguments to examine the solution and solution process afterlsqnonneg完成。

准备Cmatrix andd问题向量

C = [0.0372 0.2869 0.6861 0.7071 0.6233 0.6245 0.6344 0.6170];d = [0.8587 0.1781 0.0747 0.8405];

解决问题,请求所有输出参数。

[x,重新塑料,残留,出口,输出,lambda] = lsqnonneg(C,,,,d)
x =0 0.6929
RESNORM = 0.8315
剩余的=0.6599 -0.3119 -0.3580 0.4130
出口= 1
输出=结构with fields:迭代: 1 algorithm: 'active-set' message: 'Optimization terminated.'
兰姆达=-0.1506 -0.0000

出口is1,,,,indicating a correct solution.

x(1)= 0,以及相应的兰姆达(1)0,,,,showing the correct duality. Similarly,X(2) > 0,以及相应的兰姆达(2) = 0

输入参数

collapse all

Linear multiplier, specified as a real matrix. Represents the variableCin the problem

最小 X C Å X - d 2 2 ,,,, 在哪里 X 0。

为了兼容,Cmust equal the length ofd

Example:C= [1,2;3,-1;-4,4]

数据类型:double

附加术语,指定为真实向量。代表变量din the problem

最小 X C Å X - d 2 2 ,,,, 在哪里 X 0。

For compatibility, the length ofd必须等于行的数量C

Example:d= [1;-6;5]

数据类型:double

优化选项,指定为结构最佳集返回。You can use最佳集to set or change the values of these fields in the options structure. SeeSet Options有关详细信息。

展示

Level of display:

  • 'notify'(default) displays output only if the function does not converge.

  • 'off'or'没有任何'displays no output.

  • 'final'仅显示最终输出。

TolX

终止公差X,,,,a positive scalar. The default is10*eps*norm(c,1)*长度(c)。SeeTolerances and Stopping Criteria

Example:options = optimset('display','final')

数据类型:结构

问题结构,指定为具有以下字段的结构。

Field Name 入口

C

Real matrix

d

真实矢量

求解器

'lsqnonneg'

选项

选项结构,例如返回最佳集

获得的最简单方法问题结构ure is to export the problem from the Optimization app.

数据类型:结构

输出参数

collapse all

解决方案,作为真实向量返回。长度Xis the same as the length ofd

Squared residual norm, returned as a nonnegative scalar. Equal tonorm(c*x-d)^2

残留,作为真实矢量返回。残留是D -C*X

Reasonlsqnonneg停止,返回as an integer.

1

Function converged to a solutionX

0

迭代次数超过options.maxiter

有关优化过程的信息,作为带有字段的结构返回:

迭代

迭代数量

algorithm

'active-set'

信息

Exit message

Lagrange乘数作为真实向量返回。条目满足互补条件x'*lambda = 0。This meanslambda(i)<0什么时候X(i)大约是0,,,,and兰姆达(i)大约是0什么时候X(i) > 0

Algorithms

lsqnonneguses the algorithm described in[[1]。该算法从一组可能的基础向量开始,并计算关联的双向量兰姆达。然后,它选择对应于最大值的基础向量兰姆达将其从基础上进行交换以换取另一个可能的候选人。这一直持续到为止兰姆达≤ 0

References

[1] Lawson,C。L.和R. J. Hanson。Solving Least-Squares Problems。Upper Saddle River, NJ: Prentice Hall. 1974. Chapter 23, p. 161.

扩展功能

也可以看看

|

Introduced before R2006a

Was this topic helpful?