Python中的约束最小二乘估计 [英] Constrained least-squares estimation in Python

查看:1390
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆