Python中的约束最小二乘估计 [英] Constrained least-squares estimation in Python
问题描述
我正在尝试使用Scipy执行约束最小二乘估计,以使所有系数都在(0,1)
范围内,并且总和为1
(此功能在Matlab的LSQLIN
函数中实现). /p>
任何人都有使用Python/Scipy设置此计算的技巧.我相信我应该使用scipy.optimize.fmin_slsqp()
,但不能完全确定应将哪些参数传递给它.[1]
非常感谢您的帮助, 尼克
[1] fmin_slsqp
文档中的一个示例对于我来说很难在没有引用文本的情况下进行解析-而且我是使用Scipy的新手.
scipy-optimize SO上的-leastsq-with-bound-constraints 得到leastsq_bounds
,即
leastsq
绑定约束为0< = x_i< = 1.
它们加和为1的约束可以用相同的方法添加.
(我发现leastsq_bounds
/MINPACK在5d,10d,20d的综合测试功能上表现出色;
你有多少个变量?)
I'm trying to perform a constrained least-squares estimation using Scipy such that all of the coefficients are in the range (0,1)
and sum to 1
(this functionality is implemented in Matlab's LSQLIN
function).
Does anybody have tips for setting up this calculation using Python/Scipy. I believe I should be using scipy.optimize.fmin_slsqp()
, but am not entirely sure what parameters I should be passing to it.[1]
Many thanks for the help, Nick
[1] The one example in the documentation for fmin_slsqp
is a bit difficult for me to parse without the referenced text -- and I'm new to using Scipy.
scipy-optimize-leastsq-with-bound-constraints on SO givesleastsq_bounds
, which is
leastsq
with bound constraints such as 0 <= x_i <= 1.
The constraint that they sum to 1 can be added in the same way.
(I've found leastsq_bounds
/ MINPACK to be good on synthetic test functions in 5d, 10d, 20d;
how many variables do you have ?)
这篇关于Python中的约束最小二乘估计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!