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 ?)
博主正尝试用Scipy实现约束最小二乘估计,目标是确保所有系数在0到1范围内且总和为1,类似于Matlab的LSQLIN功能。他们考虑使用scipy.optimize.fmin_slsqp(),但不确定应传递哪些参数。已找到一个使用leastsq_bounds的方法来添加边界约束,如0<=x_i<=1,但还需添加系数总和为1的约束。询问如何在5D、10D或更高维度的问题中设置这种计算。
4573

被折叠的 条评论
为什么被折叠?



